ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-07-07 03:59:51
Exec Total Coverage
Lines: 9330 12889 72.4%
Functions: 111 141 78.7%
Branches: 7026 11973 58.7%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 416 std::map<int32_t, script_slot_data > ffcmap;
92 416 std::map<int32_t, script_slot_data > globalmap;
93 416 std::map<int32_t, script_slot_data > genericmap;
94 416 std::map<int32_t, script_slot_data > itemmap;
95 416 std::map<int32_t, script_slot_data > npcmap;
96 416 std::map<int32_t, script_slot_data > ewpnmap;
97 416 std::map<int32_t, script_slot_data > lwpnmap;
98 416 std::map<int32_t, script_slot_data > playermap;
99 416 std::map<int32_t, script_slot_data > dmapmap;
100 416 std::map<int32_t, script_slot_data > screenmap;
101 416 std::map<int32_t, script_slot_data > itemspritemap;
102 416 std::map<int32_t, script_slot_data > comboscriptmap;
103 416 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14256 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14256 return p_igetw(&unused, f);
121 }
122
123 21985 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 21979 times.
21985 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 6 output = fmt::format("{} --{}", slotname, scriptname);
129 6 break;
130 21979 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21979 output = fmt::format("{} {}", slotname, scriptname);
133 21979 }
134 21985 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 787 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 787 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 482 times.
787 if (unencrypted_result.decoded_pf)
721 305 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 482 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 482 bool compressed = unencrypted_result.compressed;
737 482 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 482 temp_name(tmpfilename);
741 char percent_done[30];
742 482 int32_t current_method=0;
743
744 PACKFILE *f;
745 482 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 482 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(strcmp(filename, "default.qst")!=0)
752 {
753 482 box_out(filename);
754 482 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 482 box_out("...");
760 482 box_eol();
761 482 box_eol();
762
763
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(encrypted)
764 {
765 482 box_out("Decrypting...");
766 482 box_save_x();
767 482 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 63 times.
482 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 482 box_out("okay.");
833 482 box_eol();
834 482 }
835 else
836 {
837 oldquest = true;
838 }
839
840 482 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if(!oldquest)
864 {
865 482 delete_file(tmpfilename);
866 482 }
867
868 482 box_out("okay.");
869 482 box_eol();
870
871 482 return f;
872 787 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readtunes(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 787 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 605 times.
✓ Branch 1 taken 182 times.
787 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 605 guys.setMax(255);
1132 605 items.setMax(255);
1133 605 Ewpns.setMax(255);
1134 605 Lwpns.setMax(255);
1135 605 chainlinks.setMax(255);
1136 605 decorations.setMax(255);
1137 605 particles.setMax(255);
1138 605 }
1139 else
1140 {
1141 182 guys.setMax(255);
1142 182 items.setMax(255);
1143 182 Ewpns.setMax(255);
1144 182 Lwpns.setMax(255);
1145 182 chainlinks.setMax(255);
1146 182 decorations.setMax(255);
1147 182 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 787 }
1150
1151 309 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 309 bool ret = true;
1154
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 79104 times.
79413 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 309 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 365 int32_t get_qst_buffers()
1199 {
1200 365 TheMaps.resize(MAPSCRS);
1201 365 old_combo_pages.resize(MAPSCRS);
1202 365 map_autolayers.resize(6);
1203
1204 365 Z_message("OK\n");
1205
1206 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1207 // (Shoelace's "Hero of Dreams" uses 1415.)
1208 // So let's be a bit generous and allow 4096 initially.
1209 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1210 // I tested it and it worked without flaw on 6/6/11. - L.
1211 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1212 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1213 // See https://discord.com/channels/876899628556091432/992984989073416242
1214 365 msg_strings_size = 8192;
1215
1216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
365 MsgStrings = new MsgStr[msg_strings_size];
1217
1218 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1219
2/2
✓ Branch 0 taken 2990080 times.
✓ Branch 1 taken 365 times.
2990445 for(auto q = 0; q < msg_strings_size; ++q)
1220 {
1221 2990080 MsgStrings[q].clear();
1222 2990080 }
1223
1224
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((DMaps=new dmap[MAXDMAPS])==NULL)
1225 return 0;
1226
1227
1228
1229 365 combobuf.clear();
1230 365 combobuf.resize(MAXCOMBOS);
1231
1232
1233
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1234 return 0;
1235
1236 365 free_newtilebuf();
1237
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1238 return 0;
1239
1240 365 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1241 //Z_message("Performed memset on tiles\n");
1242 365 clear_tiles(newtilebuf);
1243 //Z_message("Performed clear_tiles()\n");
1244
1245
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 13 times.
365 if (get_app_id() == App::zquest)
1246 {
1247
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1248 return 0;
1249
1250 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1251 13 clear_tiles(grabtilebuf);
1252 13 }
1253
1254
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((trashbuf=(byte*)malloc(100000))==NULL)
1255 return 0;
1256
1257 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1258 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1259 // fixed by ensuring there's actually itemdata there.
1260 // If you change this, be sure to update del_qst_buffers, too.
1261
1262
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1263 return 0;
1264
1265 365 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1266 365 itemsbuf++;
1267
1268
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1269 return 0;
1270
1271 365 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1272
1273
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1274 return 0;
1275
1276 365 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1277
1278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
365 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1279 return 0;
1280
1281 365 return 1;
1282 365 }
1283
1284
1285 685 void free_newtilebuf()
1286 {
1287
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 364 times.
685 if(newtilebuf)
1288 {
1289
2/2
✓ Branch 0 taken 68854500 times.
✓ Branch 1 taken 321 times.
68854821 for(int32_t i=0; i<NEWMAXTILES; i++)
1290
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 68640000 times.
137494500 if(newtilebuf[i].data)
1291 68640000 free(newtilebuf[i].data);
1292
1293 321 free(newtilebuf);
1294 321 newtilebuf = 0;
1295 321 }
1296 685 }
1297
1298 320 void free_grabtilebuf()
1299 {
1300
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 11 times.
320 if (get_app_id() == App::zquest)
1301 {
1302
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1303 {
1304
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1306
1307 11 free(grabtilebuf);
1308 11 grabtilebuf = 0;
1309 11 }
1310 11 }
1311 320 }
1312
1313 320 void del_qst_buffers()
1314 {
1315
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
320 if(MsgStrings) delete[] MsgStrings;
1316
1317
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
320 if (DMaps) delete[] DMaps;
1318
1319 320 combobuf.clear();
1320
1321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(colordata) free(colordata);
1322
1323 320 free_newtilebuf();
1324 320 free_grabtilebuf();
1325
1326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(trashbuf) free(trashbuf);
1327
1328 // See get_qst_buffers
1329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(itemsbuf)
1330 {
1331 320 itemsbuf--;
1332 320 free(itemsbuf);
1333 320 }
1334
1335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(wpnsbuf) free(wpnsbuf);
1336
1337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(guysbuf) free(guysbuf);
1338
1339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if(combo_class_buf) free(combo_class_buf);
1340 320 }
1341
1342 18 bool init_palnames()
1343 {
1344 // if(palnames==NULL)
1345 // return false;
1346
1347
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1348 {
1349
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1350 {
1351 case 0:
1352 18 sprintf(palnames[x],"Overworld");
1353 18 break;
1354
1355 case 10:
1356 18 sprintf(palnames[x],"Caves");
1357 18 break;
1358
1359 case 11:
1360 18 sprintf(palnames[x],"Passageways");
1361 18 break;
1362
1363 default:
1364 9162 sprintf(palnames[x],"%c",0);
1365 9162 break;
1366 }
1367 9216 }
1368
1369 18 return true;
1370 }
1371
1372 100088 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1373 {
1374 void *p;
1375
1376
1/2
✓ Branch 0 taken 100088 times.
✗ Branch 1 not taken.
100088 p = _AL_MALLOC(MAX(size, alloc_size));
1377
1378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100088 times.
100088 if(!p)
1379 {
1380 return NULL;
1381 }
1382
1383
1/2
✓ Branch 0 taken 100088 times.
✗ Branch 1 not taken.
100088 if(!pfread(p,size,f))
1384 {
1385 _AL_FREE(p);
1386 return NULL;
1387 }
1388
1389
1/2
✓ Branch 0 taken 100088 times.
✗ Branch 1 not taken.
100088 if(pack_ferror(f))
1390 {
1391 _AL_FREE(p);
1392 return NULL;
1393 }
1394
1395 100088 return p;
1396 100088 }
1397
1398 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1399 static const byte* legacy_skip_flags;
1400
1401 /* read_midi:
1402 * Reads MIDI data from a datafile (this is not the same thing as the
1403 * standard midi file format).
1404 */
1405
1406 10242 static MIDI *read_midi(PACKFILE *f)
1407 {
1408 MIDI *m;
1409 int32_t c;
1410 10242 int16_t divisions=0;
1411 10242 int32_t len=0;
1412
1413 10242 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1414
1415
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!m)
1416 {
1417 return NULL;
1418 }
1419
1420
2/2
✓ Branch 0 taken 327744 times.
✓ Branch 1 taken 10242 times.
337986 for(c=0; c<MIDI_TRACKS; c++)
1421 {
1422 327744 m->track[c].len = 0;
1423 327744 m->track[c].data = NULL;
1424 327744 }
1425
1426 10242 p_mgetw(&divisions,f);
1427 10242 m->divisions=divisions;
1428
1429
2/2
✓ Branch 0 taken 327744 times.
✓ Branch 1 taken 10242 times.
337986 for(c=0; c<MIDI_TRACKS; c++)
1430 {
1431 327744 p_mgetl(&len,f);
1432 327744 m->track[c].len=len;
1433
1434
2/2
✓ Branch 0 taken 227656 times.
✓ Branch 1 taken 100088 times.
327744 if(m->track[c].len > 0)
1435 {
1436 100088 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1437
1438
1/2
✓ Branch 0 taken 100088 times.
✗ Branch 1 not taken.
100088 if(!m->track[c].data)
1439 {
1440 destroy_midi(m);
1441 return NULL;
1442 }
1443 100088 }
1444 327744 }
1445
1446 LOCK_DATA(m, sizeof(MIDI));
1447
1448
2/2
✓ Branch 0 taken 327744 times.
✓ Branch 1 taken 10242 times.
337986 for(c=0; c<MIDI_TRACKS; c++)
1449 {
1450
2/2
✓ Branch 0 taken 100088 times.
✓ Branch 1 taken 227656 times.
327744 if(m->track[c].data)
1451 {
1452 LOCK_DATA(m->track[c].data, m->track[c].len);
1453 100088 }
1454 327744 }
1455
1456 10242 return m;
1457 10242 }
1458
1459 void clear_combo(int32_t i)
1460 {
1461 combobuf[i].clear();
1462 }
1463
1464 void clear_combos()
1465 {
1466 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1467 clear_combo(tmpcounter);
1468 }
1469
1470 void pack_combos()
1471 {
1472 int32_t di = 0;
1473
1474 for(int32_t si=0; si<1024; si+=2)
1475 combobuf[di++] = combobuf[si];
1476
1477 for(; di<1024; di++)
1478 clear_combo(di);
1479 }
1480
1481 469 void reset_tunes(zctune *tune)
1482 {
1483
2/2
✓ Branch 0 taken 118188 times.
✓ Branch 1 taken 469 times.
118657 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1484 {
1485 118188 tune[i].reset();
1486 118188 }
1487 469 }
1488
1489 int32_t doortranslations_u[9][4]=
1490 {
1491 {37,38,53,54},
1492 {37,38,39,40},
1493 {37,38,55,56},
1494 {37,38,39,40},
1495 {37,38,53,54},
1496 {37,38,53,54},
1497 {37,38,53,54},
1498 {7,8,23,24},
1499 {7,8,41,42}
1500 };
1501
1502 int32_t doortranslations_d[9][4]=
1503 {
1504 {117,118,133,134},
1505 {135,136,133,134},
1506 {119,120,133,134},
1507 {135,136,133,134},
1508 {117,118,133,134},
1509 {117,118,133,134},
1510 {117,118,133,134},
1511 {151,152,167,168},
1512 {137,138,167,168},
1513 };
1514
1515 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1516 int32_t doortranslations_l[9][6]=
1517 {
1518 {66,67,82,83,98,99},
1519 {66,68,82,84,98,100},
1520 {66,69,82,85,98,101},
1521 {66,68,82,84,98,100},
1522 {66,67,82,83,98,99},
1523 {66,67,82,83,98,99},
1524 {66,67,82,83,98,99},
1525 {64,65,80,81,96,97},
1526 {64,65,80,114,96,97},
1527 };
1528
1529 int32_t doortranslations_r[9][6]=
1530 {
1531
1532 {76,77,92,93,108,109},
1533 {75,77,91,93,107,109},
1534 {74,77,90,93,106,109},
1535 {75,77,91,93,107,109},
1536 {76,77,92,93,108,109},
1537 {76,77,92,93,108,109},
1538 {76,77,92,93,108,109},
1539 {78,79,94,95,110,111},
1540 {78,79,125,95,110,111},
1541 };
1542
1543 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1544 {
1545 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1546 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1547 }
1548
1549 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1550 {
1551 //these are here to bypass compiler warnings about unused arguments
1552 840750 map=map;
1553 840750 scr=scr;
1554 840750 pos=pos;
1555
1556 //what does this function do?
1557 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1558 840750 return 2;
1559 }
1560
1561 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1562 {
1563
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1564 {
1565 18423 return 0;
1566 }
1567
1568 4425 DoorComboSet tempdcs{};
1569
1570 //up
1571
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1572 {
1573
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1574 {
1575 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1576 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1577 159300 }
1578 39825 }
1579
1580 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1581 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1582 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1583 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1584 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1585 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1586
1587 //down
1588
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1589 {
1590
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1591 {
1592 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1593 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1594 159300 }
1595 39825 }
1596
1597 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1598
1599 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1600 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1601 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1602 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1603 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1604
1605 //left
1606 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1607
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1608 {
1609
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1610 {
1611 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1612 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1613 238950 }
1614 39825 }
1615
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1617 {
1618 if((j!=2)&&(j!=3))
1619 {
1620 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1621 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1622 }
1623 }
1624
1625 4425 tempdcs.bombdoorcombo_l[0]=0;
1626 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1627 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1628 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1629 4425 tempdcs.bombdoorcombo_l[2]=0;
1630 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1631 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1632 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1633
1634 //right
1635
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1636 {
1637
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1638 {
1639 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1640 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1641 238950 }
1642 39825 }
1643
1644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1645 {
1646 if((j!=2)&&(j!=3))
1647 {
1648 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1649 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1650 }
1651 }
1652
1653 4425 tempdcs.bombdoorcombo_r[0]=0;
1654 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1655 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1656 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1657 4425 tempdcs.bombdoorcombo_r[2]=0;
1658 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1659 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1660 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1661
1662 int32_t k;
1663
1664
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1665 {
1666
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1667 {
1668 4365 break;
1669 }
1670 5941 }
1671
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1673 {
1674 return 0;
1675 }
1676
1677
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1678 {
1679 60 DoorComboSets[k]=tempdcs;
1680 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1681 60 ++door_combo_set_count;
1682 60 }
1683
1684 4425 return k;
1685 /*
1686 doorcombo_u[9][4];
1687 doorcset_u[9][4];
1688 doorcombo_d[9][4];
1689 doorcset_d[9][4];
1690 doorcombo_l[9][6];
1691 doorcset_l[9][6];
1692 doorcombo_r[9][6];
1693 doorcset_r[9][6];
1694 bombdoorcombo_u[2];
1695 bombdoorcset_u[2];
1696 bombdoorcombo_d[2];
1697 bombdoorcset_d[2];
1698 bombdoorcombo_l[3];
1699 bombdoorcset_l[3];
1700 bombdoorcombo_r[3];
1701 bombdoorcset_r[3];
1702 walkthroughcombo[4];
1703 walkthroughcset[4];
1704 */
1705 22848 }
1706
1707 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1708 {
1709 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1710 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1711 }
1712
1713 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1714 {
1715
1716 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1717 }
1718
1719 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1720 {
1721 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1722 }
1723
1724
1725 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1726 {
1727 char temp_pwd[30];
1728 83 memset(temp_pwd,0,30);
1729
1730
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1731 {
1732 75 memcpy(temp_pwd,encrypted_pwd,30);
1733 75 temp_pwd[29]=0;
1734
1735
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1736 {
1737 2250 temp_pwd[i] -= pwdkey;
1738 2250 int32_t t=pwdkey>>15;
1739 2250 pwdkey = (pwdkey<<1)+t;
1740 2250 }
1741 75 }
1742
1743 83 memcpy(pwd,temp_pwd,30);
1744 83 }
1745
1746
1747 256 bool devpwd()
1748 {
1749 #ifdef _DEBUG
1750 return true;
1751 #endif
1752 #if DEVLEVEL > 3
1753 return true;
1754 #endif
1755
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1756 }
1757 bool check_questpwd(zquestheader *Header, char *pwd)
1758 {
1759 if(devpwd())
1760 return true;
1761 if((!strcmp(pwd, (char*)clavio)))
1762 return true;
1763 cvs_MD5Context ctx;
1764 uint8_t md5sum[16];
1765
1766 cvs_MD5Init(&ctx);
1767 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1768 cvs_MD5Final(md5sum, &ctx);
1769
1770 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1771 }
1772
1773 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1774 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1775 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1776
1777 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1778 {
1779 char keyfilename[2048];
1780 replace_extension(keyfilename, path, ext, 2047);
1781 if(!exists(keyfilename))
1782 return false;
1783 bool ret = false;
1784
1785 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1786 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1787 char msg[80] = {0};
1788 pfread(msg, 80, fp);
1789 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1790 {
1791 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1792 pack_fclose(fp);
1793 return false;
1794 }
1795 int16_t ver;
1796 byte bld;
1797 p_igetw(&ver, fp);
1798 p_getc(&bld, fp);
1799 pfread(password, QSTPWD_LEN, fp, true);
1800 if(hashed)
1801 {
1802 char unhashed_pw[QSTPWD_LEN] = {0};
1803
1804 char hashmap = 'Z';
1805 hashmap += 'Q';
1806 hashmap += 'U';
1807 hashmap += 'E';
1808 hashmap += 'S';
1809 hashmap += 'T';
1810
1811 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1812 unhashed_pw[q] = password[q] - hashmap;
1813
1814 ret = check_questpwd(Header, unhashed_pw);
1815 }
1816 else ret = check_questpwd(Header, password);
1817 pack_fclose(fp);
1818 zprint2("Found %s Key File '%s' (%s access)\n",
1819 typestr, keyfilename, ret ? "valid" : "invalid");
1820 return ret;
1821 }
1822
1823 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1824 {
1825 char exedir[PATH_MAX] = {0};
1826 extract_name(path, exedir, FILENAMEALL);
1827 char const* paths[] = {path, exedir};
1828 for(uint keyty : types)
1829 {
1830 if(keyty >= KEYFILE_NUMTY)
1831 continue;
1832 for(char const* p : paths)
1833 {
1834 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1835 return true;
1836 }
1837 }
1838 return false;
1839 }
1840
1841 427 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1842 {
1843 427 zprint2("\n");
1844 427 zprint2("[QUEST METADATA]\n");
1845
1/2
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
427 if(path)
1846 427 zprint2("Path: %s\n", path);
1847
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 100 times.
427 if(tempheader.title[0])
1848 327 zprint2("Title: %s\n", tempheader.title);
1849 427 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1850
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 258 times.
427 if(tempheader.new_version_id_date_day)
1851 169 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1852
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 181 times.
427 if(tempheader.version[0])
1853 246 zprint2("Qst Version: %s\n", tempheader.version);
1854
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 100 times.
427 if(tempheader.author[0])
1855 327 zprint2("Author: %s\n", tempheader.author);
1856 427 zprint2("\n");
1857 427 }
1858
1859 799 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1860 {
1861 int32_t dummy;
1862 799 zquestheader tempheader{};
1863
2/2
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 12 times.
799 tempheader.filename = Header->filename;
1864 char dummybuf[80];
1865 byte temp_map_count;
1866 byte temp_midi_flags[MIDIFLAGS_SIZE];
1867 word version;
1868 char temp_pwd[30], temp_pwd2[30];
1869 int16_t temp_pwdkey;
1870 cvs_MD5Context ctx;
1871 787 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1872 787 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1873
1874
1875
1876
2/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 787 times.
787 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1877 {
1878 Z_message("Unable to read header string\n");
1879 return qe_invalid;
1880 }
1881
1882 // check header
1883
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1884 {
1885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1886 {
1887 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1888 return qe_invalid;
1889 }
1890 24 }
1891
1892 787 int32_t templatepath_len=0;
1893
1894 787 tempheader.external_zinfo = false;
1895 787 read_zinfo = false;
1896
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1897 {
1898 byte padding;
1899
1900
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1901 {
1902 return qe_invalid;
1903 }
1904
1905
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1906 {
1907 return qe_invalid;
1908 }
1909
1910 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1911
1912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1913 {
1914 return qe_version;
1915 }
1916
1917 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1918
1919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1920 {
1921 return qe_invalid;
1922 }
1923
1924
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
1925 {
1926 return qe_obsolete;
1927 }
1928
1929
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_igetw(&tempheader.internal,f))
1930 {
1931 return qe_invalid;
1932 }
1933
1934
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.quest_number,f))
1935 {
1936 return qe_invalid;
1937 }
1938
1939 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
1940
1941
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
1942 {
1943 return qe_invalid;
1944 }
1945
1946
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
1947 {
1948 return qe_invalid;
1949 }
1950
1951 24 FFCore.quest_format[qMapCount] = temp_map_count;
1952
1953
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
1954 {
1955 return qe_invalid;
1956 }
1957
1958
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
1959 {
1960 return qe_invalid;
1961 }
1962
1963
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!pfread(temp_midi_flags,4,f))
1964 {
1965 return qe_invalid;
1966 }
1967
1968
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
1969 {
1970 return qe_invalid;
1971 }
1972
1973
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
1974 {
1975 return qe_invalid;
1976 }
1977
1978
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
1979 {
1980 return qe_invalid;
1981 }
1982
1983
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
1984 {
1985 return qe_invalid;
1986 }
1987
1988
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
1989 {
1990 return qe_invalid;
1991 }
1992
1993
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
1994 {
1995 return qe_invalid;
1996 }
1997 // These fields are expected to end in null bytes!
1998 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
1999
2000
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2001 {
2002 return qe_invalid;
2003 }
2004 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2005
2006
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2007 {
2008 return qe_invalid;
2009 }
2010
2011
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2012 {
2013 return qe_invalid;
2014 }
2015
2016
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2017 {
2018 return qe_invalid;
2019 }
2020
2021 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2022
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2023
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2024
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2025
2026
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2027 {
2028 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2029 // Not anymore...
2030 memset(tempheader.minver,0,17);
2031 tempheader.build=0;
2032 tempheader.use_keyfile=0;
2033 memset(tempheader.old_foo, 0, 9);
2034 }
2035 else
2036 {
2037
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2038 {
2039 return qe_invalid;
2040 }
2041
2042
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2043 {
2044 return qe_invalid;
2045 }
2046
2047 24 FFCore.quest_format[vBuild] = tempheader.build;
2048
2049
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2050 {
2051 return qe_invalid;
2052 }
2053
2054
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2055 {
2056 return qe_invalid;
2057 }
2058 } // starting at minver
2059
2060
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2061 {
2062 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2063 6 }
2064 else
2065 {
2066
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2067 {
2068 return qe_invalid; // starting at rules3
2069 }
2070
2071
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2072 {
2073
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2074 12 }
2075 }
2076
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2077
2078
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2079
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2080 {
2081
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2082
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2083
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2084 18 }
2085
2086
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2087 {
2088 6 byte *mf=temp_midi_flags;
2089
2090
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2091 {
2092 4 mf=(byte*)dummybuf;
2093 4 }
2094
2095
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2096 {
2097 return qe_invalid; // starting at foo2
2098 }
2099
2100
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2101 {
2102 return qe_invalid; // starting at foo2
2103 }
2104 6 }
2105
2106
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2107
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2108 {
2109 18 memset(tempheader.templatepath,0,2048);
2110 18 }
2111 else
2112 {
2113 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2114 {
2115 return qe_invalid;
2116 }
2117 }
2118
2119
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2120
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2121 {
2122 24 tempheader.use_keyfile=0;
2123 24 }
2124 24 }
2125 else
2126 {
2127 //section id
2128
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_mgetl(&dummy,f))
2129 {
2130 return qe_invalid;
2131 }
2132
2133 //section version info
2134
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetw(&version,f))
2135 {
2136 return qe_invalid;
2137 }
2138
2139 763 FFCore.quest_format[vHeader] = version;
2140
2141
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetw(&dummy,f))
2142 {
2143 return qe_invalid;
2144 }
2145
2146 //section size
2147
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetl(&dummy,f))
2148 {
2149 return qe_invalid;
2150 }
2151
2152 //finally... section data
2153
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetw(&tempheader.zelda_version,f))
2154 {
2155 return qe_invalid;
2156 }
2157
2158 763 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2159
2160 //do some quick checking...
2161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(tempheader.zelda_version > ZELDA_VERSION)
2162 {
2163 return qe_version;
2164 }
2165
2166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2167 {
2168 return qe_invalid;
2169 }
2170
2171
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 763 times.
763 if(bad_version(tempheader.zelda_version))
2172 {
2173 return qe_obsolete;
2174 }
2175
2176
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.build,f))
2177 {
2178 return qe_invalid;
2179 }
2180
2181 763 FFCore.quest_format[vBuild] = tempheader.build;
2182
2183
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 704 times.
763 if(version<3)
2184 {
2185
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2186 {
2187 return qe_invalid;
2188 }
2189
2190
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2191 {
2192 return qe_invalid;
2193 }
2194
2195 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2196
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2197
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2198
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2199 59 }
2200 else
2201 {
2202
2/4
✓ Branch 0 taken 704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
704 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2203 {
2204 return qe_invalid;
2205 }
2206 }
2207
2208
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_igetw(&tempheader.internal,f))
2209 {
2210 return qe_invalid;
2211 }
2212
2213
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.quest_number,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218 763 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2219
2220 763 size_t versz = version < 8 ? 9 : 16;
2221
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.version,versz,f))
2222 {
2223 return qe_invalid;
2224 }
2225
2226 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2227 //needs to be copied as char[9] or stored as a s.str
2228
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.minver,versz,f))
2229 {
2230 return qe_invalid;
2231 }
2232
2233 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2234
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2235 {
2236 return qe_invalid;
2237 }
2238 763 tempheader.title[sizeof(tempheader.title)-1] = 0;
2239
2240
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2241 {
2242 return qe_invalid;
2243 }
2244 763 tempheader.author[sizeof(tempheader.author)-1] = 0;
2245
2246
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.use_keyfile,f))
2247 {
2248 return qe_invalid;
2249 }
2250
2251 /*
2252 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2253 {
2254 return qe_invalid;
2255 }
2256 */
2257
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2258 {
2259 return qe_invalid;
2260 }
2261
2262
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(&dummybuf,4,f))
2263 {
2264 return qe_invalid;
2265 }
2266
2267
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2268 {
2269 return qe_invalid;
2270 }
2271
2272
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(dummybuf,14,f))
2273 {
2274 return qe_invalid;
2275 }
2276
2277 763 templatepath_len=sizeof(tempheader.templatepath);
2278
2279
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 59 times.
763 if(version==1)
2280 {
2281 59 templatepath_len=280;
2282 59 }
2283
2284
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!pfread(tempheader.templatepath,templatepath_len,f))
2285 {
2286 return qe_invalid;
2287 }
2288
2289
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_getc(&temp_map_count,f))
2290 {
2291 return qe_invalid;
2292 }
2293
2294
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 581 times.
763 if(version>=4)
2295 {
2296
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.version_major,f))
2297 {
2298 return qe_invalid;
2299 }
2300
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.version_minor,f))
2301 {
2302 return qe_invalid;
2303 }
2304
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.version_patch,f))
2305 {
2306 return qe_invalid;
2307 }
2308
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2309 {
2310 return qe_invalid;
2311 }
2312
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2313 {
2314 return qe_invalid;
2315 }
2316
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_beta,f))
2317 {
2318 return qe_invalid;
2319 }
2320
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2321 {
2322 return qe_invalid;
2323 }
2324
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.new_version_id_release,f))
2325 {
2326 return qe_invalid;
2327 }
2328
2329 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2330
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
182 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2331 tempheader.version_minor = 55;
2332
2333
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2334 {
2335 return qe_invalid;
2336 }
2337
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.new_version_id_date_month,f))
2338 {
2339 return qe_invalid;
2340 }
2341
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.new_version_id_date_day,f))
2342 {
2343 return qe_invalid;
2344 }
2345
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2346 {
2347 return qe_invalid;
2348 }
2349
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.new_version_devsig,256,f))
2355 {
2356 return qe_invalid;
2357 }
2358
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2359 strcpy(tempheader.new_version_devsig, "EmilyV99");
2360
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.new_version_compilername,256,f))
2361 {
2362 return qe_invalid;
2363 }
2364
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.new_version_compilerversion,256,f))
2365 {
2366 return qe_invalid;
2367 }
2368
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.product_name,1024,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&tempheader.compilerid,f))
2374 {
2375 return qe_invalid;
2376 }
2377
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2378 {
2379 return qe_invalid;
2380 }
2381
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2382 {
2383 return qe_invalid;
2384 }
2385
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2386 {
2387 return qe_invalid;
2388 }
2389
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2390 {
2391 return qe_invalid;
2392 }
2393
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetw(&tempheader.developerid,f))
2394 {
2395 return qe_invalid;
2396 }
2397
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
182 if(!pfread(tempheader.made_in_module_name,1024,f))
2398 {
2399 return qe_invalid;
2400 }
2401
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
182 if(!pfread(tempheader.build_datestamp,256,f))
2402 {
2403 return qe_invalid;
2404 }
2405
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
182 if(!pfread(tempheader.build_timestamp,256,f))
2406 {
2407 return qe_invalid;
2408 }
2409 182 }
2410 else // <4
2411 {
2412 581 tempheader.version_major = 0;
2413 581 tempheader.version_minor = 0;
2414 581 tempheader.version_patch = 0;
2415 581 tempheader.new_version_id_fourth = 0;
2416 581 tempheader.new_version_id_alpha = 0;
2417 581 tempheader.new_version_id_beta = 0;
2418 581 tempheader.new_version_id_gamma = 0;
2419 581 tempheader.new_version_id_release = 0;
2420 581 tempheader.new_version_id_date_year = 0;
2421 581 tempheader.new_version_id_date_month = 0;
2422 581 tempheader.new_version_id_date_day = 0;
2423 581 tempheader.new_version_id_date_hour = 0;
2424 581 tempheader.new_version_id_date_minute = 0;
2425
2426 581 memset(tempheader.new_version_devsig, 0, 256);
2427 581 memset(tempheader.new_version_compilername, 0, 256);
2428 581 memset(tempheader.new_version_compilerversion, 0, 256);
2429 581 memset(tempheader.product_name, 0, 1024);
2430 581 strcpy(tempheader.product_name, "ZQuest Classic");
2431
2432 581 tempheader.compilerid = 0;
2433 581 tempheader.compilerversionnumber_first = 0;
2434 581 tempheader.compilerversionnumber_second = 0;
2435 581 tempheader.compilerversionnumber_third = 0;
2436 581 tempheader.compilerversionnumber_fourth = 0;
2437 581 tempheader.developerid = 0;
2438
2439 581 memset(tempheader.made_in_module_name, 0, 1024);
2440 581 memset(tempheader.build_datestamp, 0, 256);
2441 581 memset(tempheader.build_timestamp, 0, 256);
2442 }
2443
2444
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 581 times.
763 if ( version >= 5 )
2445 {
2446
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(tempheader.build_timezone,6,f))
2447 {
2448 return qe_invalid;
2449 }
2450 182 }
2451 else // < 5
2452 {
2453 581 memset(tempheader.build_timezone, 0, 6);
2454 }
2455
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 581 times.
763 if ( version >= 6 )
2456 {
2457 byte b;
2458
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&b,f))
2459 {
2460 return qe_invalid;
2461 }
2462 182 tempheader.external_zinfo = b?true:false;
2463 182 read_zinfo = true;
2464 182 }
2465
2466
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 581 times.
763 if(version >= 7)
2467 {
2468
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2469 {
2470 return qe_invalid;
2471 }
2472 182 }
2473 else
2474 {
2475 581 tempheader.new_version_is_nightly = false;
2476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 581 times.
581 if(tempheader.zelda_version < 0x255)
2477 {
2478
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
581 switch(tempheader.zelda_version)
2479 {
2480 case 0x254:
2481 tempheader.version_major = 2;
2482 tempheader.version_minor = 54;
2483 break;
2484 case 0x250:
2485
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 399 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 28 times.
✓ Branch 15 taken 16 times.
522 switch(tempheader.build)
2486 {
2487 case 19:
2488 tempheader.version_major = 2;
2489 tempheader.version_minor = 50;
2490 tempheader.new_version_id_gamma = 1;
2491 break;
2492 case 20:
2493 tempheader.version_major = 2;
2494 tempheader.version_minor = 50;
2495 tempheader.new_version_id_gamma = 2;
2496 break;
2497 case 21:
2498 tempheader.version_major = 2;
2499 tempheader.version_minor = 50;
2500 tempheader.new_version_id_gamma = 3;
2501 break;
2502 case 22:
2503 tempheader.version_major = 2;
2504 tempheader.version_minor = 50;
2505 tempheader.new_version_id_gamma = 4;
2506 break;
2507 case 23:
2508 tempheader.version_major = 2;
2509 tempheader.version_minor = 50;
2510 tempheader.new_version_id_gamma = 5;
2511 break;
2512 case 24:
2513 33 tempheader.version_major = 2;
2514 33 tempheader.version_minor = 50;
2515 33 tempheader.new_version_id_release = -1;
2516 33 break;
2517 case 25:
2518 tempheader.version_major = 2;
2519 tempheader.version_minor = 50;
2520 tempheader.version_patch = 1;
2521 tempheader.new_version_id_gamma = 1;
2522 break;
2523 case 26:
2524 24 tempheader.version_major = 2;
2525 24 tempheader.version_minor = 50;
2526 24 tempheader.version_patch = 1;
2527 24 tempheader.new_version_id_gamma = 2;
2528 24 break;
2529 case 27:
2530 tempheader.version_major = 2;
2531 tempheader.version_minor = 50;
2532 tempheader.version_patch = 1;
2533 tempheader.new_version_id_gamma = 3;
2534 break;
2535 case 28:
2536 6 tempheader.version_major = 2;
2537 6 tempheader.version_minor = 50;
2538 6 tempheader.version_patch = 1;
2539 6 tempheader.new_version_id_release = -1;
2540 6 break;
2541 case 29:
2542 399 tempheader.version_major = 2;
2543 399 tempheader.version_minor = 50;
2544 399 tempheader.version_patch = 2;
2545 399 tempheader.new_version_id_release = -1;
2546 399 break;
2547 case 30:
2548 tempheader.version_major = 2;
2549 tempheader.version_minor = 50;
2550 tempheader.version_patch = 3;
2551 tempheader.new_version_id_gamma = 1;
2552 break;
2553 case 31:
2554 16 tempheader.version_major = 2;
2555 16 tempheader.version_minor = 53;
2556 16 tempheader.new_version_id_gamma = -1;
2557 16 break;
2558 case 32:
2559 28 tempheader.version_major = 2;
2560 28 tempheader.version_minor = 53;
2561 28 tempheader.new_version_id_release = -1;
2562 28 break;
2563 case 33:
2564 16 tempheader.version_major = 2;
2565 16 tempheader.version_minor = 53;
2566 16 tempheader.version_patch = 1;
2567 16 break;
2568 }
2569 522 break;
2570
2571 case 0x211:
2572 tempheader.version_major = 2;
2573 tempheader.version_minor = 11;
2574 tempheader.new_version_id_beta = tempheader.build;
2575 break;
2576 case 0x210:
2577 59 tempheader.version_major = 2;
2578 59 tempheader.version_minor = 10;
2579 59 tempheader.new_version_id_beta = tempheader.build;
2580 59 break;
2581 }
2582 581 }
2583 }
2584
2585
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 625 times.
763 if (version>=9)
2586 {
2587 138 std::string version_string;
2588
2/4
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
✗ Branch 3 not taken.
138 if(!p_getcstr(&version_string, f))
2589 {
2590 return qe_invalid;
2591 }
2592
2593 138 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2594 138 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 }
2596 else
2597 {
2598 625 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2599 }
2600 }
2601
2602
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 775 times.
787 if(printmetadata)
2603 {
2604
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2605 12 }
2606
2607 //{ Version Warning
2608
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 int32_t vercmp = tempheader.compareVer();
2609
3/6
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 787 times.
✗ Branch 5 not taken.
787 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2610
2/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 787 times.
✗ Branch 3 not taken.
787 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2611
4/6
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
✓ Branch 3 taken 649 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 138 times.
925 if(vercmp > 0 || (!vercmp &&
2612
2/4
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
✗ Branch 3 not taken.
138 (astatecmp > 0 || (!astatecmp &&
2613 138 avercmp > 0))))
2614 {
2615 bool r = true;
2616 if(loadquest_report)
2617 {
2618 enter_sys_pal();
2619 AlertDialog("Quest saved in newer version",
2620 "This quest was last saved in a newer version of ZQuest."
2621 " Attempting to load this quest may not work correctly; to"
2622 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2623 "\n\nWould you like to continue loading anyway? (Not recommended)",
2624 [&](bool ret,bool)
2625 {
2626 r = ret;
2627 }).show();
2628 exit_sys_pal();
2629 }
2630 if(!r)
2631 return qe_silenterr;
2632 }
2633
2/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 787 times.
✗ Branch 3 not taken.
787 else if(tempheader.compareDate() > 0)
2634 {
2635 bool r = true;
2636 if(loadquest_report)
2637 {
2638 enter_sys_pal();
2639 AlertDialog("Quest saved in newer build",
2640 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2641 " issues loading in this build."
2642 "\n{}"
2643 "\n\nWould you like to continue loading anyway?",
2644 tempheader.getVerCmpStr()),
2645 [&](bool ret,bool)
2646 {
2647 r = ret;
2648 }).show();
2649 exit_sys_pal();
2650 }
2651 if(!r)
2652 return qe_silenterr;
2653 }
2654 //}
2655
2656 787 read_ext_zinfo = tempheader.external_zinfo;
2657
2658
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 *Header = tempheader;
2659 787 map_count=temp_map_count;
2660 787 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2661
2662
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 unpack_qrs();
2663
2664 787 return 0;
2665 811 }
2666
2667 6587 int32_t readrules(PACKFILE *f, zquestheader *Header)
2668 {
2669
2/2
✓ Branch 0 taken 6564 times.
✓ Branch 1 taken 23 times.
6587 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6587 times.
6587 if (should_skip)
2671 return 0;
2672
2673 int32_t dummy;
2674 6587 zquestheader tempheader = *Header;
2675 6587 word s_version=0;
2676 6587 dword compatrule_version=0;
2677
2678
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 6141 times.
6587 if(tempheader.zelda_version >= 0x193)
2679 {
2680 //section version info
2681
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&s_version,f))
2682 {
2683 return qe_invalid;
2684 }
2685
2686 446 FFCore.quest_format[vRules] = s_version;
2687
2688
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&dummy,f))
2689 {
2690 return qe_invalid;
2691 }
2692
2693
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 264 times.
446 if(s_version > 16)
2694 {
2695
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!p_igetl(&compatrule_version,f))
2696 {
2697 return qe_invalid;
2698 }
2699 182 }
2700 446 FFCore.quest_format[vCompatRule] = compatrule_version;
2701
2702 //section size
2703
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy,f))
2704 {
2705 return qe_invalid;
2706 }
2707
2708
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 182 times.
446 if ( s_version < 15 )
2709 {
2710 //finally... section data
2711
2/4
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
264 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2712 {
2713 return qe_invalid;
2714 }
2715 264 }
2716 else
2717 {
2718
2719
2/4
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2720 {
2721 return qe_invalid;
2722 }
2723
2724 }
2725 446 }
2726
2727 //{ bunch of compat stuff
2728 6587 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2729
2730
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 6118 times.
6587 unpack_qrs();
2731
2732
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<2)
2733 {
2734
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2735
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2736
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2737
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2738
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2739
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2740
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2741
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2742
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2743
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2744
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2745
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2746
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2747
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2748
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2749
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2750
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2751
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2752
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2753 82 }
2754
2755 //Now, do any updates...
2756
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
469 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2757 {
2758
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2759
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2760
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2761
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2762
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2763 82 }
2764
2765
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
469 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2766 {
2767
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2768 23 }
2769
2770
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
469 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2771 {
2772
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2773 23 }
2774
2775
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
469 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2776 {
2777
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2778 23 }
2779
2780
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(tempheader.zelda_version <= 0x210)
2781 {
2782
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2783 82 }
2784
2785
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 410 times.
469 if(tempheader.zelda_version == 0x210)
2786 {
2787
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2788
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2789
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2790 59 }
2791
2792
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(tempheader.zelda_version <= 0x210)
2793 {
2794
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2795
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2796 82 }
2797
2798 //might not be correct
2799
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if(tempheader.zelda_version < 0x210)
2800 {
2801
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2802
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2803
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2804 23 }
2805
2806
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(tempheader.zelda_version < 0x211)
2807 {
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2809 82 }
2810
2811
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 464 times.
469 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2812 {
2813
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 447 times.
469 set_qr(qr_192b163_WARP,1);
2814 22 }
2815
2816
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 47 times.
22 if(tempheader.zelda_version == 0x210)
2817 {
2818
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2819
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2820
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2821 59 }
2822
2823
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 281 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
106 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2824 {
2825
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 199 times.
281 set_qr(qr_OLDPICKUP,1);
2826 82 }
2827
2828
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
469 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2829 {
2830
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2831
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2832 82 }
2833
2834
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2835 {
2836
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2837 82 }
2838
2839
4/4
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 264 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 172 times.
469 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2840 {
2841
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_PEAHATCLOCKVULN, 1);
2842 33 }
2843
2844
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
469 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2845 {
2846
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 set_qr(qr_OLD_DOORREPAIR, 1);
2847 82 }
2848
2849
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
264 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2850 {
2851
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
328 set_qr(qr_OLD_SECRETMONEY, 1);
2852 82 }
2853
2854
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
264 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2855 {
2856
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 189 times.
328 set_qr(qr_OLD_POTION_OR_HC, 1);
2857 139 }
2858
2859
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
321 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2860 {
2861
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 132 times.
271 set_qr(qr_OFFSCREENWEAPONS, 1);
2862 139 }
2863
2864 //Bombchu fix.
2865
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 205 times.
321 if(tempheader.zelda_version == 0x250)
2866 {
2867
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 172 times.
205 if ( tempheader.build == 24 ) //2.50.0
2868 {
2869
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2870 33 }
2871
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 199 times.
205 if ( tempheader.build == 28 ) //2.50.1
2872 {
2873
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2874 6 }
2875
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 123 times.
205 if ( tempheader.build == 29 ) //2.50.2
2876 {
2877
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2878 82 }
2879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if ( tempheader.build == 30 ) //2.50.3RC1
2880 {
2881 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2882 }
2883 205 }
2884
2885
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
321 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2886 {
2887 // qr_OFFSETEWPNCOLLISIONFIX
2888 // All 'official' quests need this disabled.
2889 // All 2.10 and lower quests need this enabled to preseve compatability.
2890 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2891
2892 //~Gleeok
2893
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 126 times.
271 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2894
2895 // Broke in build 695
2896
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
145 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2897
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_BROKENSTATUES, 1);
2898 145 }
2899
11/14
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 451 times.
✓ Branch 2 taken 446 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 570 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 570 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 553 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
327 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2900 {
2901
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2902 22 }
2903
8/8
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 370 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 198 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 182 times.
✓ Branch 7 taken 16 times.
575 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2904 {
2905
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 288 times.
559 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2906 271 }
2907
2908
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 205 times.
287 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2909 {
2910
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2911 82 }
2912
2913
4/6
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 182 times.
287 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2914 {
2915
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 136 times.
151 set_qr(qr_STEP_IS_FLOAT,0);
2916 287 }
2917
2918
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if ( tempheader.zelda_version < 0x250 )
2919 {
2920
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2921 82 }
2922
2923
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version < 3)
2924 {
2925
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2926
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2927 82 }
2928
2929
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<4)
2930 {
2931
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2932 82 }
2933
2934
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<5)
2935 {
2936
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2937 82 }
2938
2939
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<6)
2940 {
2941
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
2942 82 }
2943
2944
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<7) // January 2008
2945 {
2946
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
2947
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
2948 82 }
2949
2950
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<8)
2951 {
2952
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
2953 82 }
2954 else
2955 {
2956
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 set_bit(deprecated_rules, 12, 0);
2957 }
2958
2959
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<9) // October 2008
2960 {
2961
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
2962
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
2963
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
2964
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
2965 82 }
2966
2967
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<10) // December 2008
2968 {
2969
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
2970
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
2971 82 }
2972
2973
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<11) // April 2009
2974 {
2975
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
2976 82 }
2977
2978 // This served no purpose.
2979 // if(s_version<12) // December 2009
2980 // {
2981 // set_qr(qr_BRKBLSHLDS_DEP,0);
2982 // set_qr(qr_OLDTRIBBLES_DEP,0);
2983 // }
2984
2985 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
2986
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version < 13)
2987 {
2988
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
2989 82 }
2990
2991 // Not entirely sure this is the best place for this...
2992 //2.50.2 bitmap offset fix
2993 469 memset(extra_rules, 0, EXTRARULES_SIZE);
2994
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
469 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2995 {
2996
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 142 times.
287 set_er(er_BITMAPOFFSET, 1);
2997
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 set_qr(qr_BITMAPOFFSETFIX, 1);
2998 145 }
2999 //required because quest templates also used this bit, although
3000 //it never did anything, before. -Z
3001
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 122 times.
327 if ( tempheader.zelda_version == 0x250 )
3002 {
3003
5/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 107 times.
205 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3004 {
3005
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_er(er_BITMAPOFFSET, 0);
3006
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_qr(qr_BITMAPOFFSETFIX, 0);
3007 98 }
3008 205 }
3009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if ( tempheader.zelda_version == 0x254 )
3010 {
3011 set_er(er_BITMAPOFFSET, 0);
3012 set_qr(qr_BITMAPOFFSETFIX, 0);
3013 }
3014
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
327 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3015 {
3016 set_er(er_BITMAPOFFSET, 0);
3017 set_qr(qr_BITMAPOFFSETFIX, 0);
3018 }
3019 //optimise fast drawing for older versions.
3020
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
327 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3021 {
3022
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 96 times.
327 set_qr(qr_OLDSPRITEDRAWS, 1);
3023 287 }
3024 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3025 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3026 //older quests can set the rule by hand. We need a new qst.dat again.
3027
4/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3028 {
3029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364 times.
364 set_qr(qr_OLDEWPNPARENT, 1);
3030 }
3031
4/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3032 {
3033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364 times.
364 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3034 }
3035
4/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 287 times.
287 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3036 {
3037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364 times.
364 set_qr(qr_OLDQUESTMISC, 1);
3038 }
3039
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x254 )
3040 {
3041
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3042
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDEWPNPARENT, 0);
3043
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDQUESTMISC, 0);
3044 287 }
3045
3046 //item scripts continue to run
3047
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3048 {
3049
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3050
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3051
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3052
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3053
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3054
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3055
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3056 287 }
3057
3058
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3059 {
3060
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3061 287 }
3062
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3063 {
3064
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_TRACESCRIPTIDS, 0);
3065
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3066
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3067
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_250DIVISION,1);
3068
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3069
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3070
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_FORCE_INLINE,0);
3071
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PARSER_BINARY_32BIT,0);
3072
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 278 times.
287 if ( get_qr(qr_SELECTAWPN) )
3073 {
3074
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3075 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3076 //Now they **do**, unless you disable that behaviour.
3077 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3078 //now enable the disable L/R item swap on load.
3079 9 }
3080
3081 287 }
3082
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3083 {
3084 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3085
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3086 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3087 //animations ending earlier than they should.
3088
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3089 //Enemies would ignore solidity on the top half of combos
3090
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3091 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3092
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3093 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3094
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3095 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3096
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3097 287 }
3098
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x255 )
3099 {
3100
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NOFFCWAITDRAW, 1);
3101
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NOITEMWAITDRAW, 1);
3102
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3103
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3104 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3105 287 }
3106
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3107 {
3108
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3109 287 }
3110
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3111 {
3112
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_OLD_PRINTF_ARGS, 1);
3113 287 }
3114
3115
3116
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3117 {
3118
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_BROKEN_RING_POWER, 1);
3119 287 }
3120
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3121 {
3122
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3123 287 }
3124
5/6
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136 times.
✓ Branch 5 taken 46 times.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3125 {
3126
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3127 287 }
3128
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
333 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3129 {
3130 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
333 if(get_qr(qr_SET_XBUTTON_ITEMS))
3132 set_qr(qr_SET_YBUTTON_ITEMS,1);
3133 287 }
3134
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3135 {
3136
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3137 287 }
3138
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3139 {
3140
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_OLD_CHEST_COLLISION,1);
3141 287 }
3142
3143
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if ( tempheader.zelda_version < 0x254 )
3144 {
3145
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3146 287 }
3147 //Sideview spikes in 2.50.0
3148
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
287 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3149 {
3150
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 178 times.
317 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3151 139 }
3152 //more 2.50 fixes -Z
3153
4/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 182 times.
321 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3154 {
3155
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 52 times.
271 set_qr(qr_MELEEMAGICCOST, 0);
3156
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3157
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_OLDMIRRORCOMBOS, 1);
3158
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENBOOKCOST, 1);
3159
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENCHARINTDRAWING, 1);
3160
3161 227 }
3162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
409 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3163 {
3164 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3165 set_qr(qr_MELEEMAGICCOST, 1);
3166 }
3167
3168
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 386 times.
409 if(tempheader.zelda_version < 0x193)
3169 {
3170
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3171 23 }
3172
3173
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 122 times.
409 if(tempheader.zelda_version < 0x255)
3174 {
3175
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDINFMAGIC, 1);
3176 287 }
3177
3178
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 327 times.
409 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3179 {
3180
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3181 82 }
3182
3183
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
409 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3184 {
3185
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 122 times.
409 set_qr(qr_OLD_F6,1);
3186 287 }
3187
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3188 {
3189
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3190 287 }
3191
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3192 {
3193
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3194 287 }
3195
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
287 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3196 {
3197
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 46 times.
333 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3198 287 }
3199 //}
3200
3201
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3202
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3203
3204
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 2) //Old CSet2 Handling
3205
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLDCS2,1);
3206
3207
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3208
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3209
3210
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3211
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3212
3213
3/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 82 times.
287 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3214
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3215
3216
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3217
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3218
3219
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3220
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3221
3222
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3223
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3224
3225
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 9)
3226 {
3227 //Hardcoded BS Patras
3228
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_HARDCODED_BS_PATRA,1);
3229 //Hardcoded Patra Inner Eye offsets
3230
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3231 //Broken 'Big enemy' animation style
3232
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3233 //Broken Attribute 31/32
3234
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3235 287 }
3236
3237
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 10) //Shared candle use limits
3238
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3239
3240
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 11) //No cross-screen return points
3241
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_RESPAWN_POINTS,1);
3242
3243
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 12)
3244 {
3245 //Old fire trail duration
3246
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3247 //Old Intro String in Ganon Room Behavior
3248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
287 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3249
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 else set_qr(qr_GANONINTRO,1);
3250 287 }
3251
3252
2/4
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 287 times.
287 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3253 set_qr(qr_ANONE_NOANIM,1);
3254
3255
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 14) //Old Bridge Combo Behavior
3256
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3257
3258
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 15) //Broken Z3 Animation
3259
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3260
3261
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3262
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3263
3264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 17)
3265 {
3266 //Old Quake/DrawYOffset behavior
3267 //set_qr(qr_OLD_DRAWOFFSET,1);
3268 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3269 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3270 287 }
3271
3272
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 18)
3273 {
3274 //Broken DrawScreen Derivative Functions
3275
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3276 //Scrolling Cancels Charge
3277
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3278 287 }
3279
3280
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3281
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3282
3283
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 20)
3284
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3285
3286
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 21)
3287 {
3288
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3289
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3290
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3291
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_BUG_NET,1);
3292
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3293 287 }
3294
3295
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 22)
3296
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3297
3298
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 23)
3299
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_HALF_MAGIC,1);
3300
3301
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 24)
3302 {
3303
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3304
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3305 287 }
3306
3307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 25)
3308 {
3309
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
287 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3310
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3311
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3312 287 }
3313
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 if(compatrule_version < 26)
3314 {
3315
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3316
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_POLVIRE_NO_SHADOW,1);
3317
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3318 287 }
3319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3320 {
3321
2/2
✓ Branch 0 taken 86387 times.
✓ Branch 1 taken 287 times.
86674 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3322
1/2
✓ Branch 0 taken 86387 times.
✗ Branch 1 not taken.
86387 set_qr(q,0);
3323
2/2
✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 287 times.
2009 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3324
1/2
✓ Branch 0 taken 1722 times.
✗ Branch 1 not taken.
1722 set_qr(q,0);
3325 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3326 287 }
3327
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
287 if(compatrule_version < 28)
3328
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3329
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 29)
3330
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3331
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 30)
3332 {
3333
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_DECO_2_YOFFSET,1);
3334
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_SCREENSTATE_80s_BUG,1);
3335 292 }
3336
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 31)
3337 {
3338
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3339
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3340 292 }
3341
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 32)
3342
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3343
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 33)
3344
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_NO_LIFT_SPRITE,1);
3345
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5 times.
297 if(compatrule_version < 34)
3346 {
3347
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3348
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3349
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3350
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3351 292 }
3352
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 35)
3353 {
3354
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3355
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3356 294 }
3357
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 3 times.
297 if(compatrule_version < 36)
3358
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 set_qr(qr_OLD_SHALLOW_SFX,1);
3359
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1 times.
297 if(compatrule_version < 37)
3360
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3361
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1 times.
299 if(compatrule_version < 38)
3362
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3363
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1 times.
299 if(compatrule_version < 39)
3364
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3365
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 1 times.
299 if(compatrule_version < 40)
3366
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3367
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
299 if(compatrule_version < 41)
3368
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKENHITBY,1);
3369
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 42)
3370
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3371
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 43)
3372
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_OLD_BOMB_HITBOXES,1);
3373
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 44)
3374
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3375
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 45)
3376
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3377
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 3 times.
303 if(compatrule_version < 46)
3378
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3379
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
303 if(compatrule_version < 47)
3380 {
3381
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3382
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3383 304 }
3384
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 48)
3385
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_GUY_HANDLING,1);
3386
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 49)
3387
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3388
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 50)
3389
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3390
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 51)
3391
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3392
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if (compatrule_version < 52)
3393
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3394
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 53)
3395 {
3396
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_SUBSCR,1);
3397
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3398
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3399 304 }
3400
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 54)
3401
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3402
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 55)
3403
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3404
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 56)
3405
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3406
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 57)
3407
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3408
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 58)
3409
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3410
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 59)
3411
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3412
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 60)
3413
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3414
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 61)
3415
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3416
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 5 times.
309 if(compatrule_version < 62)
3417
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3418
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 4 times.
309 if(compatrule_version < 63)
3419 {
3420
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_LIFTSWIM,1);
3421
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3422 305 }
3423
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 4 times.
309 if(compatrule_version < 64)
3424
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3425
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 21 times.
309 if(compatrule_version < 65)
3426
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3427
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
351 if(compatrule_version < 66)
3428
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3429
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if(compatrule_version < 67)
3430
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3431
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if(compatrule_version < 68)
3432
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3433
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if(compatrule_version < 69)
3434
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3435
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if (compatrule_version < 70)
3436
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_CONVEYORS, 1);
3437
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if (compatrule_version < 71)
3438
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3439
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if (compatrule_version < 72)
3440
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3441
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
353 if (compatrule_version < 73)
3442 {
3443
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_OLD_LANDING_SFX, 1);
3444
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3445 332 }
3446
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
353 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3447
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3448
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 352 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
684 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3449
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3450
5/6
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 683 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
1015 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3451
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 331 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3452
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 996 times.
1346 if (compatrule_version < 77)
3453
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3454
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 996 times.
1346 if (compatrule_version < 78)
3455
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3456
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 996 times.
1346 if (compatrule_version < 79)
3457
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3458
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 996 times.
1346 if (compatrule_version < 80)
3459
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3460
3461
3/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 1015 times.
✓ Branch 2 taken 331 times.
✗ Branch 3 not taken.
1346 if (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0)
3462
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 546 times.
1015 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3463
3464
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 331 times.
800 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3465
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 182 times.
469 if (s_version < 16)
3466
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3467
3468
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 *Header = tempheader;
3469
3470 469 return 0;
3471 12705 }
3472
3473 3983401 void init_msgstr(MsgStr *str)
3474 {
3475
2/4
✓ Branch 0 taken 3983401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3983401 times.
3983401 str->setFromLegacyEncoding("");
3476 3983401 str->nextstring=0;
3477 3983401 str->tile=0;
3478 3983401 str->cset=0;
3479 3983401 str->trans=false;
3480 3983401 str->font=font_zfont;
3481 3983401 str->y=32;
3482 3983401 str->sfx=18;
3483 3983401 str->listpos=0;
3484 3983401 str->x=24;
3485 3983401 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3486 3983401 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3487 3983401 str->hspace=0;
3488 3983401 str->vspace=0;
3489 3983401 str->stringflags=0;
3490 3983401 str->margins[up] = 8;
3491 3983401 str->margins[down] = 0;
3492 3983401 str->margins[left] = 8;
3493 3983401 str->margins[right] = 8;
3494 3983401 str->portrait_tile = 0;
3495 3983401 str->portrait_cset = 0;
3496 3983401 str->portrait_x = 0;
3497 3983401 str->portrait_y = 0;
3498 3983401 str->portrait_tw = 1;
3499 3983401 str->portrait_th = 1;
3500 3983401 str->shadow_type = 0;
3501 3983401 str->shadow_color = 0;
3502 3983401 str->drawlayer = 6;
3503 3983401 }
3504
3505 469 void init_msgstrings(int32_t start, int32_t end)
3506 {
3507
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
469 if(end <= start || end-start > msg_strings_size)
3508 return;
3509
3510
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 3842048 times.
3842517 for(int32_t i=start; i<end; i++)
3511 {
3512 3842048 init_msgstr(&MsgStrings[i]);
3513 3842048 MsgStrings[i].listpos=i;
3514 3842048 }
3515
3516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(start==0)
3517 {
3518
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
469 MsgStrings[0].setFromLegacyEncoding("(None)");
3519 469 MsgStrings[0].listpos = 0;
3520 469 }
3521 469 }
3522
3523 470 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3524 {
3525
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3526
3527 470 MsgStr tempMsgString;
3528
1/2
✓ Branch 0 taken 470 times.
✗ Branch 1 not taken.
470 init_msgstr(&tempMsgString);
3529
3530 470 word temp_msg_count=0;
3531 word temp_expansion[16];
3532 470 memset(temp_expansion, 0, 16*sizeof(word));
3533 470 char buf[8193] = {0};
3534
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 if(Header->zelda_version < 0x193)
3535 {
3536 byte tempbyte;
3537 24 int32_t strings_to_read=0;
3538
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3539
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3540
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3541
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3542 {
3543 18 strings_to_read=128;
3544 18 temp_msg_count=Header->old_str_count;
3545
3546 // Some sort of string count corruption seems to be common in old quests
3547
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3548 {
3549 temp_msg_count=128;
3550 }
3551 18 }
3552
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3553 {
3554 strings_to_read=255;
3555 temp_msg_count=Header->old_str_count;
3556 }
3557 else
3558 {
3559
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3560 {
3561 return qe_invalid;
3562 }
3563
3564 6 strings_to_read=temp_msg_count;
3565
3566
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3567 {
3568 Z_message("Reallocating string buffer...\n");
3569
3570 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3571 // return qe_nomem;
3572
3573 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3574 delete[] MsgStrings;
3575 MsgStrings = new MsgStr[MAXMSGS];
3576 msg_strings_size = MAXMSGS;
3577 for(auto q = 0; q < msg_strings_size; ++q)
3578 {
3579 MsgStrings[q].clear();
3580 }
3581 }
3582 }
3583
3584 //reset the message strings
3585
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3586
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3587
3588
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3589 {
3590
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3591 2550 tempMsgString.listpos = x;
3592
3593
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3594 {
3595 return qe_invalid;
3596 }
3597
3598 2550 buf[74] = '\0';
3599
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3600
3601
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3602 {
3603 return qe_invalid;
3604 }
3605
3606
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3607
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3608 {
3609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3610
3611
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3612 {
3613 return qe_invalid;
3614 }
3615
3616
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3617 {
3618 return qe_invalid;
3619 }
3620 2304 }
3621 else
3622 {
3623
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3624 {
3625 return qe_invalid;
3626 }
3627
3628
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3629 {
3630 return qe_invalid;
3631 }
3632 }
3633
3634
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3635 {
3636
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3637 2549 }
3638 2550 }
3639 24 }
3640 else
3641 {
3642 int32_t dummy_int;
3643 word s_version;
3644
3645 //section version info
3646
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&s_version,f))
3647 {
3648 return qe_invalid;
3649 }
3650
3651 446 FFCore.quest_format[vStrings] = s_version;
3652
3653
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!read_deprecated_section_cversion(f))
3654 {
3655 return qe_invalid;
3656 }
3657
3658 //section size
3659
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy_int,f))
3660 {
3661 return qe_invalid;
3662 }
3663
3664 //finally... section data
3665
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&temp_msg_count,f))
3666 {
3667 return qe_invalid;
3668 }
3669
3670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
446 if(temp_msg_count >= msg_strings_size && !should_skip)
3671 {
3672 Z_message("Reallocating string buffer...\n");
3673
3674 delete[] MsgStrings;
3675 MsgStrings = new MsgStr[MAXMSGS];
3676 msg_strings_size = MAXMSGS;
3677 for(auto q = 0; q < msg_strings_size; ++q)
3678 {
3679 MsgStrings[q].clear();
3680 }
3681 }
3682
3683 //reset the message strings
3684
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 182 times.
446 if(s_version < 7)
3685
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3686
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if (!should_skip)
3687
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 init_msgstrings(0,msg_strings_size);
3688
3689 446 int32_t string_length=(s_version<2)?73:145;
3690
3691
2/2
✓ Branch 0 taken 138333 times.
✓ Branch 1 taken 446 times.
138779 for(int32_t i=0; i<temp_msg_count; i++)
3692 {
3693
1/2
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
138333 init_msgstr(&tempMsgString);
3694 138333 tempMsgString.listpos = i;
3695
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 132539 times.
138333 if(s_version > 8)
3696 {
3697
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_igetl(&string_length,f))
3698 {
3699 return qe_invalid;
3700 }
3701 5794 }
3702
3703
2/4
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 138333 times.
138333 if (string_length < 0 || string_length > 8193)
3704 {
3705 return qe_invalid;
3706 }
3707
3708
2/2
✓ Branch 0 taken 137781 times.
✓ Branch 1 taken 552 times.
138333 if (string_length > 0)
3709 {
3710
2/4
✓ Branch 0 taken 137781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137781 times.
✗ Branch 3 not taken.
137781 if (!pfread(buf, string_length, f))
3711 {
3712 return qe_invalid;
3713 }
3714 137781 }
3715 else
3716 {
3717 552 buf[0] = 0;
3718 }
3719
3720
2/4
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 138333 times.
✗ Branch 3 not taken.
138333 if(!p_igetw(&tempMsgString.nextstring,f))
3721 {
3722 return qe_invalid;
3723 }
3724
3725
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 104720 times.
138333 if(s_version<2)
3726 {
3727 33613 buf[72] = '\0';
3728
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3729 33613 }
3730 else
3731 {
3732 // June 2008: A bug corrupted the last 4 chars of a string.
3733 // Discard these.
3734
1/2
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
104720 if(s_version<3)
3735 {
3736 for(int32_t j=140; j<144; j++)
3737 {
3738 buf[j] = '\0';
3739 }
3740 }
3741
1/2
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
104720 if(string_length > 8192) string_length = 8192;
3742 104720 buf[string_length]='\0'; //Force-terminate
3743
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104720 times.
104720 tempMsgString.setFromLegacyEncoding(buf);
3744
3745
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 98926 times.
104720 if ( s_version >= 6 )
3746 {
3747
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_igetl(&tempMsgString.tile,f))
3748 {
3749 return qe_invalid;
3750 }
3751 5794 }
3752 else
3753 {
3754
2/4
✓ Branch 0 taken 98926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98926 times.
✗ Branch 3 not taken.
98926 if(!p_igetw(&tempMsgString.tile,f))
3755 {
3756 return qe_invalid;
3757 }
3758 }
3759
3760
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.cset,f))
3761 {
3762 return qe_invalid;
3763 }
3764
3765 byte dummy_char;
3766
3767
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3768 {
3769 return qe_invalid;
3770 }
3771
3772 104720 tempMsgString.trans=dummy_char!=0;
3773
3774
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.font,f))
3775 {
3776 return qe_invalid;
3777 }
3778
3779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104720 times.
104720 if(s_version < 5)
3780 {
3781 if(!p_getc(&tempMsgString.y,f))
3782 {
3783 return qe_invalid;
3784 }
3785 }
3786 else
3787 {
3788
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.x,f))
3789 {
3790 return qe_invalid;
3791 }
3792
3793
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.y,f))
3794 {
3795 return qe_invalid;
3796 }
3797
3798
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.w,f))
3799 {
3800 return qe_invalid;
3801 }
3802
3803
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.h,f))
3804 {
3805 return qe_invalid;
3806 }
3807
3808
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.hspace,f))
3809 {
3810 return qe_invalid;
3811 }
3812
3813
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.vspace,f))
3814 {
3815 return qe_invalid;
3816 }
3817
3818
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.stringflags,f))
3819 {
3820 return qe_invalid;
3821 }
3822 }
3823
3824
2/2
✓ Branch 0 taken 98926 times.
✓ Branch 1 taken 5794 times.
104720 if(s_version >= 7)
3825 {
3826
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 23176 times.
28970 for(int32_t q = 0; q < 4; ++q)
3827 {
3828
2/4
✓ Branch 0 taken 23176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23176 times.
✗ Branch 3 not taken.
23176 if(!p_getc(&tempMsgString.margins[q],f))
3829 {
3830 return qe_invalid;
3831 }
3832 23176 }
3833
3834
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_igetl(&tempMsgString.portrait_tile,f))
3835 {
3836 return qe_invalid;
3837 }
3838
3839
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_cset,f))
3840 {
3841 return qe_invalid;
3842 }
3843
3844
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_x,f))
3845 {
3846 return qe_invalid;
3847 }
3848
3849
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_y,f))
3850 {
3851 return qe_invalid;
3852 }
3853
3854
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_tw,f))
3855 {
3856 return qe_invalid;
3857 }
3858
3859
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.portrait_th,f))
3860 {
3861 return qe_invalid;
3862 }
3863 5794 }
3864
3865
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 98926 times.
104720 if(s_version >= 8)
3866 {
3867
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.shadow_type,f))
3868 {
3869 return qe_invalid;
3870 }
3871
3872
2/4
✓ Branch 0 taken 5794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5794 times.
✗ Branch 3 not taken.
5794 if(!p_getc(&tempMsgString.shadow_color,f))
3873 {
3874 return qe_invalid;
3875 }
3876 5794 }
3877
3878
2/2
✓ Branch 0 taken 5485 times.
✓ Branch 1 taken 99235 times.
104720 if(s_version >= 10)
3879 {
3880
2/4
✓ Branch 0 taken 5485 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5485 times.
✗ Branch 3 not taken.
5485 if(!p_getc(&tempMsgString.drawlayer,f))
3881 {
3882 return qe_invalid;
3883 }
3884 5485 }
3885
3886
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_getc(&tempMsgString.sfx,f))
3887 {
3888 return qe_invalid;
3889 }
3890
3891
1/2
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
104720 if(s_version>3)
3892 {
3893
2/4
✓ Branch 0 taken 104720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104720 times.
✗ Branch 3 not taken.
104720 if(!p_igetw(&tempMsgString.listpos,f))
3894 {
3895 return qe_invalid;
3896 }
3897 104720 }
3898 }
3899
3900
1/2
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
138333 if (!should_skip)
3901 {
3902
1/2
✓ Branch 0 taken 138333 times.
✗ Branch 1 not taken.
138333 MsgStrings[i].copyAll(tempMsgString);
3903 138333 }
3904 138333 }
3905 }
3906
3907
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (!should_skip)
3908 469 msg_count=temp_msg_count;
3909
3910 470 return 0;
3911 470 }
3912
3913 470 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
3914 {
3915
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
3916
3917
3/4
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
476 if((Header->zelda_version < 0x192)||
3918
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 446 times.
452 ((Header->zelda_version == 0x192)&&(Header->build<158)))
3919 {
3920 18 return 0;
3921 }
3922
3923 452 word temp_door_combo_set_count=0;
3924 DoorComboSet tempDoorComboSet;
3925 word dummy_word;
3926 int32_t dummy_long;
3927 byte padding;
3928 452 int32_t s_version = 0;
3929
3930
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 451 times.
452 if (!should_skip)
3931 {
3932 451 DoorComboSets = {};
3933 451 DoorComboSetNames = {};
3934 451 }
3935
3936
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 446 times.
452 if(Header->zelda_version > 0x192)
3937 {
3938 //section version info
3939
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&s_version,f))
3940 {
3941 return qe_invalid;
3942 }
3943
3944 446 FFCore.quest_format[vDoors] = s_version;
3945
3946
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&dummy_word,f))
3947 {
3948 return qe_invalid;
3949 }
3950
3951 //section size
3952
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy_long,f))
3953 {
3954 return qe_invalid;
3955 }
3956 446 }
3957
3958 //finally... section data
3959
1/2
✓ Branch 0 taken 452 times.
✗ Branch 1 not taken.
452 if(!p_igetw(&temp_door_combo_set_count,f))
3960 {
3961 return qe_invalid;
3962 }
3963
3964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452 times.
452 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
3965 {
3966 return qe_invalid;
3967 }
3968
3969
2/2
✓ Branch 0 taken 5334 times.
✓ Branch 1 taken 452 times.
5786 for(int32_t i=0; i<temp_door_combo_set_count; i++)
3970 {
3971 5334 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
3972
3973 //name
3974 char name[21];
3975
1/2
✓ Branch 0 taken 5334 times.
✗ Branch 1 not taken.
5334 if(!pfread(&name,sizeof(name),f))
3976 {
3977 return qe_invalid;
3978 }
3979
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5320 times.
5334 if (!should_skip)
3980 5320 DoorComboSetNames[i] = name;
3981
3982
2/2
✓ Branch 0 taken 5294 times.
✓ Branch 1 taken 40 times.
5334 if(Header->zelda_version < 0x193)
3983 {
3984
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
3985 {
3986 return qe_invalid;
3987 }
3988 40 }
3989
3990 //up door
3991
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
3992 {
3993
2/2
✓ Branch 0 taken 192024 times.
✓ Branch 1 taken 48006 times.
240030 for(int32_t k=0; k<4; k++)
3994 {
3995
1/2
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
192024 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
3996 {
3997 return qe_invalid;
3998 }
3999 192024 }
4000 48006 }
4001
4002
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4003 {
4004
2/2
✓ Branch 0 taken 192024 times.
✓ Branch 1 taken 48006 times.
240030 for(int32_t k=0; k<4; k++)
4005 {
4006
1/2
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
192024 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4007 {
4008 return qe_invalid;
4009 }
4010 192024 }
4011 48006 }
4012
4013 //down door
4014
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4015 {
4016
2/2
✓ Branch 0 taken 192024 times.
✓ Branch 1 taken 48006 times.
240030 for(int32_t k=0; k<4; k++)
4017 {
4018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192024 times.
192024 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4019 {
4020 return qe_invalid;
4021 }
4022 192024 }
4023 48006 }
4024
4025
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4026 {
4027
2/2
✓ Branch 0 taken 192024 times.
✓ Branch 1 taken 48006 times.
240030 for(int32_t k=0; k<4; k++)
4028 {
4029
1/2
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
192024 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4030 {
4031 return qe_invalid;
4032 }
4033 192024 }
4034 48006 }
4035
4036 //left door
4037
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4038 {
4039
2/2
✓ Branch 0 taken 288036 times.
✓ Branch 1 taken 48006 times.
336042 for(int32_t k=0; k<6; k++)
4040 {
4041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288036 times.
288036 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4042 {
4043 return qe_invalid;
4044 }
4045 288036 }
4046 48006 }
4047
4048
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4049 {
4050
2/2
✓ Branch 0 taken 288036 times.
✓ Branch 1 taken 48006 times.
336042 for(int32_t k=0; k<6; k++)
4051 {
4052
1/2
✓ Branch 0 taken 288036 times.
✗ Branch 1 not taken.
288036 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4053 {
4054 return qe_invalid;
4055 }
4056 288036 }
4057 48006 }
4058
4059 //right door
4060
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4061 {
4062
2/2
✓ Branch 0 taken 288036 times.
✓ Branch 1 taken 48006 times.
336042 for(int32_t k=0; k<6; k++)
4063 {
4064
1/2
✓ Branch 0 taken 288036 times.
✗ Branch 1 not taken.
288036 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4065 {
4066 return qe_invalid;
4067 }
4068 288036 }
4069 48006 }
4070
4071
2/2
✓ Branch 0 taken 48006 times.
✓ Branch 1 taken 5334 times.
53340 for(int32_t j=0; j<9; j++)
4072 {
4073
2/2
✓ Branch 0 taken 288036 times.
✓ Branch 1 taken 48006 times.
336042 for(int32_t k=0; k<6; k++)
4074 {
4075
1/2
✓ Branch 0 taken 288036 times.
✗ Branch 1 not taken.
288036 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4076 {
4077 return qe_invalid;
4078 }
4079 288036 }
4080 48006 }
4081
4082 //up bomb rubble
4083
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4084 {
4085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4086 {
4087 return qe_invalid;
4088 }
4089 10668 }
4090
4091
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4092 {
4093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4094 {
4095 return qe_invalid;
4096 }
4097 10668 }
4098
4099 //down bomb rubble
4100
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4101 {
4102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4103 {
4104 return qe_invalid;
4105 }
4106 10668 }
4107
4108
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4109 {
4110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4111 {
4112 return qe_invalid;
4113 }
4114 10668 }
4115
4116 //left bomb rubble
4117
2/2
✓ Branch 0 taken 16002 times.
✓ Branch 1 taken 5334 times.
21336 for(int32_t j=0; j<3; j++)
4118 {
4119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16002 times.
16002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4120 {
4121 return qe_invalid;
4122 }
4123 16002 }
4124
4125
2/2
✓ Branch 0 taken 16002 times.
✓ Branch 1 taken 5334 times.
21336 for(int32_t j=0; j<3; j++)
4126 {
4127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16002 times.
16002 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4128 {
4129 return qe_invalid;
4130 }
4131 16002 }
4132
4133
2/2
✓ Branch 0 taken 5294 times.
✓ Branch 1 taken 40 times.
5334 if(Header->zelda_version < 0x193)
4134 {
4135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4136 {
4137 return qe_invalid;
4138 }
4139
4140 40 }
4141
4142 //right bomb rubble
4143
2/2
✓ Branch 0 taken 16002 times.
✓ Branch 1 taken 5334 times.
21336 for(int32_t j=0; j<3; j++)
4144 {
4145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16002 times.
16002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4146 {
4147 return qe_invalid;
4148 }
4149 16002 }
4150
4151
2/2
✓ Branch 0 taken 16002 times.
✓ Branch 1 taken 5334 times.
21336 for(int32_t j=0; j<3; j++)
4152 {
4153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16002 times.
16002 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4154 {
4155 return qe_invalid;
4156 }
4157 16002 }
4158
4159
2/2
✓ Branch 0 taken 5294 times.
✓ Branch 1 taken 40 times.
5334 if(Header->zelda_version < 0x193)
4160 {
4161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4162 {
4163 return qe_invalid;
4164 }
4165 40 }
4166
4167 //walkthrough stuff
4168
2/2
✓ Branch 0 taken 21336 times.
✓ Branch 1 taken 5334 times.
26670 for(int32_t j=0; j<4; j++)
4169 {
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21336 times.
21336 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4171 {
4172 return qe_invalid;
4173 }
4174 21336 }
4175
4176
2/2
✓ Branch 0 taken 21336 times.
✓ Branch 1 taken 5334 times.
26670 for(int32_t j=0; j<4; j++)
4177 {
4178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21336 times.
21336 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4179 {
4180 return qe_invalid;
4181 }
4182 21336 }
4183
4184 //flags
4185
2/2
✓ Branch 0 taken 10668 times.
✓ Branch 1 taken 5334 times.
16002 for(int32_t j=0; j<2; j++)
4186 {
4187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10668 times.
10668 if(!p_getc(&tempDoorComboSet.flags[j],f))
4188 {
4189 return qe_invalid;
4190 }
4191 10668 }
4192
4193
2/2
✓ Branch 0 taken 5294 times.
✓ Branch 1 taken 40 times.
5334 if(Header->zelda_version < 0x193)
4194 {
4195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4196 {
4197 return qe_invalid;
4198 }
4199 40 }
4200
4201
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5320 times.
5334 if (!should_skip)
4202 5320 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4203 5334 }
4204
4205
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 451 times.
452 if (!should_skip)
4206 451 door_combo_set_count=temp_door_combo_set_count;
4207
4208 452 return 0;
4209 470 }
4210
4211 9 int32_t count_dmaps()
4212 {
4213 9 int32_t i=MAXDMAPS-1;
4214 9 bool found=false;
4215
4216
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4217 {
4218
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4219
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4220
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4221 18 found=true;
4222
4223
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4224 {
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4226
4227 found=true;
4228 72 }
4229
4230
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4231 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4232 27 found=true;
4233
4234
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4235
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4236
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4237
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4238 18 found=true;
4239
4240 if(!found)
4241 {
4242 i--;
4243 }
4244 }
4245
4246 9 return i+1;
4247 }
4248
4249
4250 9 int32_t count_shops(miscQdata *Misc)
4251 {
4252 9 int32_t i=NUM_SHOPS-1,j;
4253 9 bool found=false;
4254
4255
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4256 {
4257 2229 j=2;
4258
4259
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4260 {
4261
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4262 {
4263 5 found=true;
4264 5 }
4265 else
4266 {
4267 6672 j--;
4268 }
4269 }
4270
4271
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4272 {
4273 found=true;
4274 }
4275
4276
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4277 {
4278 2224 i--;
4279 2224 }
4280 }
4281
4282 9 return i+1;
4283 }
4284
4285 9 int32_t count_infos(miscQdata *Misc)
4286 {
4287 9 int32_t i=255,j;
4288 9 bool found=false;
4289
4290
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4291 {
4292 2229 j=2;
4293
4294
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4295 {
4296
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4297 {
4298 5 found=true;
4299 5 }
4300 else
4301 {
4302 6672 j--;
4303 }
4304 }
4305
4306
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4307 {
4308 found=true;
4309 }
4310
4311
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4312 {
4313 2224 i--;
4314 2224 }
4315 }
4316
4317 9 return i+1;
4318 }
4319
4320 9 int32_t count_warprings(miscQdata *Misc)
4321 {
4322 9 int32_t i=15,j;
4323 9 bool found=false;
4324
4325
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4326 {
4327 49 j=7;
4328
4329
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4330 {
4331
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4332 {
4333 9 found=true;
4334 9 }
4335 else
4336 {
4337 349 j--;
4338 }
4339 }
4340
4341
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4342 {
4343 40 i--;
4344 40 }
4345 }
4346
4347 9 return i+1;
4348 }
4349
4350 9 int32_t count_palcycles(miscQdata *Misc)
4351 {
4352 9 int32_t i=255,j;
4353 9 bool found=false;
4354
4355
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4356 {
4357 2036 j=2;
4358
4359
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4360 {
4361
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4362 {
4363 7 found=true;
4364 7 }
4365 else
4366 {
4367 6087 j--;
4368 }
4369 }
4370
4371
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4372 {
4373 2029 i--;
4374 2029 }
4375 }
4376
4377 9 return i+1;
4378 }
4379
4380 18088 void clear_screen(mapscr *temp_scr)
4381 {
4382 18088 temp_scr->zero_memory();
4383 18088 }
4384
4385 // NOTE: when modifying this, you need to also update:
4386 // readonedmap, readdmaps, and FFScript::read_dmaps
4387 // (and their associated write functions)
4388 3542 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4389 {
4390
2/2
✓ Branch 0 taken 3518 times.
✓ Branch 1 taken 24 times.
3542 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4391
4392 3542 word dmapstoread=0;
4393 3542 dmap tempDMap;
4394
4395 int32_t dummy;
4396 3542 word s_version=0;
4397 byte padding;
4398
4399 char legacy_title[22];
4400
4401
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 469 times.
3542 if (!should_skip)
4402
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<max_dmaps; i++)
4403 {
4404
1/2
✓ Branch 0 taken 240128 times.
✗ Branch 1 not taken.
240128 DMaps[start_dmap + i].clear();
4405 240128 sprintf(legacy_title," ");
4406 240128 sprintf(DMaps[start_dmap+i].intro," ");
4407 240128 DMaps[start_dmap+i].type |= dmCAVE;
4408 240597 }
4409
4410
3/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
3542 if (!should_skip && s_version == 21)
4411 Regions = {};
4412
4413 3542 Header->is_z3 = false;
4414
4/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 446 times.
✓ Branch 3 taken 24 times.
3542 if(!Header || Header->zelda_version > 0x192)
4415 {
4416 //section version info
4417
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
3518 if(!p_igetw(&s_version,f))
4418 {
4419 return qe_invalid;
4420 }
4421 446 Header->is_z3 = s_version >= 22;
4422
4423 446 FFCore.quest_format[vDMaps] = s_version;
4424
4425
4426
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!read_deprecated_section_cversion(f))
4427 {
4428 return qe_invalid;
4429 }
4430
4431 //section size
4432
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy,f))
4433 {
4434 return qe_invalid;
4435 }
4436
4437 //finally... section data
4438
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&dmapstoread,f))
4439 {
4440 return qe_invalid;
4441 }
4442 446 }
4443 else
4444 {
4445
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4446
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4447 {
4448 18 dmapstoread=32;
4449 18 }
4450
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4451 {
4452 6 dmapstoread=OLDMAXDMAPS;
4453 6 }
4454 else
4455 {
4456 dmapstoread=MAXDMAPS;
4457 }
4458 }
4459
4460
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 387 times.
470 dmapstoread=zc_min(dmapstoread, max_dmaps);
4461
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 387 times.
470 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4462
4463
2/2
✓ Branch 0 taken 215360 times.
✓ Branch 1 taken 470 times.
215830 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4464 {
4465
1/2
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
215360 tempDMap.clear();
4466 215360 sprintf(legacy_title," ");
4467 215360 sprintf(tempDMap.intro," ");
4468
4469
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.map,f))
4470 {
4471 return qe_invalid;
4472 }
4473
4474
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 198144 times.
215360 if(s_version <= 4)
4475 {
4476 byte tempbyte;
4477
4478
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4479 {
4480 return qe_invalid;
4481 }
4482
4483 17216 tempDMap.level=(word)tempbyte;
4484 17216 }
4485 else
4486 {
4487
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_igetw(&tempDMap.level,f))
4488 {
4489 return qe_invalid;
4490 }
4491 }
4492
4493
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.xoff,f))
4494 {
4495 return qe_invalid;
4496 }
4497
4498
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.compass,f))
4499 {
4500 return qe_invalid;
4501 }
4502
4503
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version > 8) // February 2009
4504 {
4505
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_igetw(&tempDMap.color,f))
4506 {
4507 return qe_invalid;
4508 }
4509 198144 }
4510 else
4511 {
4512 byte tempbyte;
4513
4514
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4515 {
4516 return qe_invalid;
4517 }
4518
4519 17216 tempDMap.color = (word)tempbyte;
4520 }
4521
4522
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.midi,f))
4523 {
4524 return qe_invalid;
4525 }
4526
4527
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.cont,f))
4528 {
4529 return qe_invalid;
4530 }
4531
4532
2/4
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215360 times.
✗ Branch 3 not taken.
215360 if(!p_getc(&tempDMap.type,f))
4533 {
4534 return qe_invalid;
4535 }
4536
4537
4/4
✓ Branch 0 taken 5932 times.
✓ Branch 1 taken 209428 times.
✓ Branch 2 taken 5888 times.
✓ Branch 3 taken 44 times.
221292 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4538
1/2
✓ Branch 0 taken 5932 times.
✗ Branch 1 not taken.
5932 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4539 5888 tempDMap.xoff = 0;
4540
4541
2/2
✓ Branch 0 taken 215360 times.
✓ Branch 1 taken 1722880 times.
1938240 for(int32_t j=0; j<8; j++)
4542 {
4543
2/4
✓ Branch 0 taken 1722880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1722880 times.
✗ Branch 3 not taken.
1722880 if(!p_getc(&tempDMap.grid[j],f))
4544 {
4545 return qe_invalid;
4546 }
4547 1722880 }
4548
4549
5/6
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 213248 times.
215360 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4550 {
4551
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4552 {
4553 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4554 127 }
4555
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4556
4557
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4558 {
4559
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4560
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4561 18 }
4562
4563 //forgotten -DD
4564
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4565 {
4566 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4567 439 }
4568 576 }
4569 else
4570 {
4571
3/4
✓ Branch 0 taken 214784 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
213248 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4572 {
4573 return qe_invalid;
4574 }
4575
4576
2/2
✓ Branch 0 taken 130304 times.
✓ Branch 1 taken 84480 times.
214784 if(s_version<20)
4577 {
4578
2/4
✓ Branch 0 taken 130304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130304 times.
✗ Branch 3 not taken.
130304 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4579 {
4580 return qe_invalid;
4581 }
4582
1/2
✓ Branch 0 taken 130304 times.
✗ Branch 1 not taken.
130304 tempDMap.title.assign(legacy_title);
4583 130304 }
4584 else
4585 {
4586
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_getwstr(&tempDMap.title, f))
4587 {
4588 return qe_invalid;
4589 }
4590 }
4591
4592
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4593 {
4594 return qe_invalid;
4595 }
4596
4597
5/8
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 213248 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
214784 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4598 {
4599 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4600 DMaps[i] = tempDMap;
4601
4602 continue;
4603 }
4604
4605
3/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 213248 times.
214784 if(Header && (Header->zelda_version < 0x193))
4606 {
4607
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4608 {
4609 return qe_invalid;
4610 }
4611 1536 }
4612
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 121600 times.
214784 if ( s_version >= 11 )
4613 {
4614
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4615 {
4616 return qe_invalid;
4617 }
4618 93184 }
4619 else
4620 {
4621
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4622 {
4623 return qe_invalid;
4624 }
4625 }
4626
4627
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getc(&tempDMap.minimap_cset[0],f))
4628 {
4629 return qe_invalid;
4630 }
4631
4632
3/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 213248 times.
214784 if(Header && (Header->zelda_version < 0x193))
4633 {
4634
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4635 {
4636 return qe_invalid;
4637 }
4638 1536 }
4639
4640
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 121600 times.
214784 if ( s_version >= 11 )
4641 {
4642
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4643 {
4644 return qe_invalid;
4645 }
4646 93184 }
4647 else
4648 {
4649
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4650 {
4651 return qe_invalid;
4652 }
4653 }
4654
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getc(&tempDMap.minimap_cset[1],f))
4655 {
4656 return qe_invalid;
4657 }
4658
4659
3/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 213248 times.
214784 if(Header && (Header->zelda_version < 0x193))
4660 {
4661
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4662 {
4663 return qe_invalid;
4664 }
4665 1536 }
4666
4667
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 121600 times.
214784 if ( s_version >= 11 )
4668 {
4669
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4670 {
4671 return qe_invalid;
4672 }
4673 93184 }
4674 else
4675 {
4676
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4677 {
4678 return qe_invalid;
4679 }
4680 }
4681
4682
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getc(&tempDMap.largemap_cset[0],f))
4683 {
4684 return qe_invalid;
4685 }
4686
4687
3/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 213248 times.
214784 if(Header && (Header->zelda_version < 0x193))
4688 {
4689
4690
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4691 {
4692 return qe_invalid;
4693 }
4694 1536 }
4695
4696
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 121600 times.
214784 if ( s_version >= 11 )
4697 {
4698
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4699 {
4700 return qe_invalid;
4701 }
4702 93184 }
4703 else
4704 {
4705
2/4
✓ Branch 0 taken 121600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121600 times.
✗ Branch 3 not taken.
121600 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4706 {
4707 return qe_invalid;
4708 }
4709 }
4710
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getc(&tempDMap.largemap_cset[1],f))
4711 {
4712 return qe_invalid;
4713 }
4714
4715
2/4
✓ Branch 0 taken 214784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214784 times.
✗ Branch 3 not taken.
214784 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4716 {
4717 return qe_invalid;
4718 }
4719 }
4720
4721
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version>1)
4722 {
4723
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_getc(&tempDMap.tmusictrack,f))
4724 {
4725 return qe_invalid;
4726 }
4727
4728
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_getc(&tempDMap.active_subscreen,f))
4729 {
4730 return qe_invalid;
4731 }
4732
4733
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_getc(&tempDMap.passive_subscreen,f))
4734 {
4735 return qe_invalid;
4736 }
4737 198144 }
4738
4739
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version>2)
4740 {
4741 byte di[32];
4742
4743
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!pfread(&di, 32, f)) return qe_invalid;
4744
4745
2/2
✓ Branch 0 taken 50724864 times.
✓ Branch 1 taken 198144 times.
50923008 for(int32_t j=0; j<MAXITEMS; j++)
4746 {
4747
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 50715657 times.
50724864 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4748 50715657 else tempDMap.disableditems[j]=0;
4749 50724864 }
4750 198144 }
4751
4752
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version >= 6)
4753 {
4754
2/4
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198144 times.
✗ Branch 3 not taken.
198144 if(!p_igetl(&tempDMap.flags,f))
4755 {
4756 return qe_invalid;
4757 }
4758 198144 }
4759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4760 {
4761 char temp;
4762
4763 if(!p_getc(&temp,f))
4764 {
4765 return qe_invalid;
4766 }
4767
4768 tempDMap.flags = temp;
4769 }
4770
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4771 {
4772 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4773 8992 }
4774 else
4775 8224 tempDMap.flags=0;
4776
4777
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version<7)
4778 {
4779
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4780 6146 tempDMap.flags|= dmfVIEWMAP;
4781 17216 }
4782
4783
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 17216 times.
215360 if(s_version<8)
4784 {
4785
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4786 {
4787
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4788 8050 tempDMap.type |= dmCAVE;
4789 8050 }
4790
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4791 {
4792 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4793 2332 }
4794 17216 }
4795
4796
7/8
✓ Branch 0 taken 215360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 213248 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 213248 times.
215360 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4797 214784 && (Header->zelda_version < 0x193))
4798 {
4799
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4800 {
4801 return qe_invalid;
4802 }
4803 1536 }
4804
4805
2/2
✓ Branch 0 taken 122176 times.
✓ Branch 1 taken 93184 times.
215360 if(s_version >= 10)
4806 {
4807
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_getc(&tempDMap.sideview,f))
4808 {
4809 return qe_invalid;
4810 }
4811 93184 }
4812
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version < 10) tempDMap.sideview = 0;
4813
4814 //Dmap Scripts
4815
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version >= 12)
4816 {
4817
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.script,f))
4818 {
4819 return qe_invalid;
4820 }
4821
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
4822 {
4823
2/4
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745472 times.
✗ Branch 3 not taken.
745472 if(!p_igetl(&tempDMap.initD[q],f))
4824 {
4825 return qe_invalid;
4826 }
4827 745472 }
4828 93184 }
4829
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if ( s_version < 12 )
4830 {
4831 122176 tempDMap.script = 0;
4832
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for ( int32_t q = 0; q < 8; q++ )
4833 {
4834 977408 tempDMap.initD[q] = 0;
4835 977408 }
4836 122176 }
4837
4838
2/2
✓ Branch 0 taken 122176 times.
✓ Branch 1 taken 93184 times.
215360 if(s_version >= 13)
4839 {
4840
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
4841 {
4842
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; w++ )
4843 {
4844
2/4
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48455680 times.
✗ Branch 3 not taken.
48455680 if(!p_getc(&tempDMap.initD_label[q][w],f))
4845 {
4846 return qe_invalid;
4847 }
4848 48455680 }
4849 745472 }
4850 93184 }
4851
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if ( s_version < 13 )
4852 {
4853 122176 tempDMap.script = 0;
4854
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for ( int32_t q = 0; q < 8; q++ )
4855 {
4856
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for ( int32_t w = 0; w < 65; w++ )
4857 63531520 tempDMap.initD_label[q][w] = 0;
4858 977408 }
4859 122176 }
4860
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version >= 14)
4861 {
4862
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.active_sub_script,f))
4863 {
4864 return qe_invalid;
4865 }
4866
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.passive_sub_script,f))
4867 {
4868 return qe_invalid;
4869 }
4870
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; ++q )
4871 {
4872
2/4
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745472 times.
✗ Branch 3 not taken.
745472 if(!p_igetl(&tempDMap.sub_initD[q],f))
4873 {
4874 return qe_invalid;
4875 }
4876 745472 }
4877
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for(int32_t q = 0; q < 8; ++q)
4878 {
4879
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; ++w )
4880 {
4881
2/4
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48455680 times.
✗ Branch 3 not taken.
48455680 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4882 {
4883 return qe_invalid;
4884 }
4885 48455680 }
4886 745472 }
4887 93184 }
4888 else
4889 {
4890 122176 tempDMap.active_sub_script = 0;
4891 122176 tempDMap.passive_sub_script = 0;
4892
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for(int32_t q = 0; q < 8; ++q)
4893 {
4894 977408 tempDMap.sub_initD[q] = 0;
4895
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for(int32_t w = 0; w < 65; ++w)
4896 63531520 tempDMap.sub_initD_label[q][w] = 0;
4897 977408 }
4898 }
4899
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version >= 15)
4900 {
4901
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.onmap_script,f))
4902 {
4903 return qe_invalid;
4904 }
4905
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; ++q )
4906 {
4907
2/4
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745472 times.
✗ Branch 3 not taken.
745472 if(!p_igetl(&tempDMap.onmap_initD[q],f))
4908 {
4909 return qe_invalid;
4910 }
4911 745472 }
4912
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for(int32_t q = 0; q < 8; ++q)
4913 {
4914
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; ++w )
4915 {
4916
2/4
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48455680 times.
✗ Branch 3 not taken.
48455680 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
4917 {
4918 return qe_invalid;
4919 }
4920 48455680 }
4921 745472 }
4922 93184 }
4923 else
4924 {
4925 122176 tempDMap.onmap_script = 0;
4926
2/2
✓ Branch 0 taken 977408 times.
✓ Branch 1 taken 122176 times.
1099584 for(int32_t q = 0; q < 8; ++q)
4927 {
4928 977408 tempDMap.onmap_initD[q] = 0;
4929
2/2
✓ Branch 0 taken 63531520 times.
✓ Branch 1 taken 977408 times.
64508928 for(int32_t w = 0; w < 65; ++w)
4930 {
4931 63531520 tempDMap.onmap_initD_label[q][w] = 0;
4932 63531520 }
4933 977408 }
4934 }
4935
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 122176 times.
215360 if(s_version >= 16)
4936 {
4937
2/4
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
93184 if(!p_igetw(&tempDMap.mirrorDMap,f))
4938 {
4939 return qe_invalid;
4940 }
4941 93184 }
4942 else
4943 {
4944 122176 tempDMap.mirrorDMap = -1;
4945 }
4946
4947 // Enhanced music loop points
4948
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 130880 times.
215360 if (s_version >= 18)
4949 {
4950
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
4951 {
4952 return qe_invalid;
4953 }
4954
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
4955 {
4956 return qe_invalid;
4957 }
4958
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
4959 {
4960 return qe_invalid;
4961 }
4962
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
4963 {
4964 return qe_invalid;
4965 }
4966 84480 }
4967 else
4968 {
4969 130880 tempDMap.tmusic_loop_start = 0;
4970 130880 tempDMap.tmusic_loop_end = 0;
4971 130880 tempDMap.tmusic_xfade_in = 0;
4972 130880 tempDMap.tmusic_xfade_out = 0;
4973 }
4974
4975
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 130880 times.
215360 if(s_version >= 19)
4976
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if(!p_getc(&tempDMap.overlay_subscreen, f))
4977 return qe_invalid;
4978
4979
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 130880 times.
215360 if (s_version >= 20)
4980 {
4981
2/4
✓ Branch 0 taken 84480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84480 times.
✗ Branch 3 not taken.
84480 if (!p_igetl(&tempDMap.intro_string_id, f))
4982 return qe_invalid;
4983 84480 }
4984 else
4985 130880 tempDMap.intro_string_id = 0;
4986
4987
2/2
✓ Branch 0 taken 201024 times.
✓ Branch 1 taken 14336 times.
215360 if(s_version == 21)
4988 {
4989 static regions_data tmp_rd;
4990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
4991
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
4992 {
4993
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
4994 {
4995
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
4996 {
4997 return qe_invalid;
4998 }
4999 917504 }
5000 114688 }
5001 14336 }
5002
5003
2/2
✓ Branch 0 taken 215104 times.
✓ Branch 1 taken 256 times.
215360 if (!should_skip)
5004 {
5005
1/2
✓ Branch 0 taken 215104 times.
✗ Branch 1 not taken.
215104 if(loading_tileset_flags & TILESET_CLEARMAPS)
5006 tempDMap.map = 0;
5007
1/2
✓ Branch 0 taken 215104 times.
✗ Branch 1 not taken.
215104 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5008 {
5009 tempDMap.script = 0;
5010 for(int q = 0; q < 8; ++q)
5011 tempDMap.initD[q] = 0;
5012 }
5013
1/2
✓ Branch 0 taken 215104 times.
✗ Branch 1 not taken.
215104 DMaps[i] = tempDMap;
5014 215104 }
5015 215360 }
5016
5017 470 return 0;
5018 6614 }
5019
5020 387 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5021 {
5022 //these are here to bypass compiler warnings about unused arguments
5023 387 Header=Header;
5024
5025 miscQdata temp_misc;
5026 387 word s_version=0;
5027 387 int32_t tempsize=0;
5028 word dummyw;
5029
5030 387 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5031
5032 //section version info
5033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
5034 {
5035 return qe_invalid;
5036 }
5037
5038 387 FFCore.quest_format[vColours] = s_version;
5039
5040 387 al_trace("Misc Colours section version: %d\n", s_version);
5041
5042
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
5043 {
5044 return qe_invalid;
5045 }
5046
5047
5048 //section size
5049
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&tempsize,f))
5050 {
5051 return qe_invalid;
5052 }
5053
5054 //finally... section data
5055 387 readsize=0;
5056
5057
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.text,f))
5058 {
5059 return qe_invalid;
5060 }
5061
5062
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.caption,f))
5063 {
5064 return qe_invalid;
5065 }
5066
5067
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.overw_bg,f))
5068 {
5069 return qe_invalid;
5070 }
5071
5072
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5073 {
5074 return qe_invalid;
5075 }
5076
5077
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5078 {
5079 return qe_invalid;
5080 }
5081
5082
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.cave_fg,f))
5083 {
5084 return qe_invalid;
5085 }
5086
5087
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.bs_dk,f))
5088 {
5089 return qe_invalid;
5090 }
5091
5092
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.bs_goal,f))
5093 {
5094 return qe_invalid;
5095 }
5096
5097
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.compass_lt,f))
5098 {
5099 return qe_invalid;
5100 }
5101
5102
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.compass_dk,f))
5103 {
5104 return qe_invalid;
5105 }
5106
5107
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5108 {
5109 return qe_invalid;
5110 }
5111
5112
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.triframe_color,f))
5113 {
5114 return qe_invalid;
5115 }
5116
5117
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.hero_dot,f))
5118 {
5119 return qe_invalid;
5120 }
5121
5122
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5123 {
5124 return qe_invalid;
5125 }
5126
5127
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5128 {
5129 return qe_invalid;
5130 }
5131
5132
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5133 {
5134 return qe_invalid;
5135 }
5136
5137
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5138 {
5139 return qe_invalid;
5140 }
5141
5142
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5143 {
5144 return qe_invalid;
5145 }
5146
5147
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5148 {
5149 return qe_invalid;
5150 }
5151
5152
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5153 {
5154 return qe_invalid;
5155 }
5156
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(s_version < 4)
5157 {
5158
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5159 return qe_invalid;
5160 205 temp_misc.colors.triforce_tile = dummyw;
5161
5162
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5163 return qe_invalid;
5164 205 temp_misc.colors.triframe_tile = dummyw;
5165
5166
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5167 return qe_invalid;
5168 205 temp_misc.colors.overworld_map_tile = dummyw;
5169
5170
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5171 return qe_invalid;
5172 205 temp_misc.colors.dungeon_map_tile = dummyw;
5173
5174
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5175 return qe_invalid;
5176 205 temp_misc.colors.blueframe_tile = dummyw;
5177
5178
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&dummyw,f))
5179 return qe_invalid;
5180 205 temp_misc.colors.HCpieces_tile = dummyw;
5181 205 }
5182
5183
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5184 {
5185 return qe_invalid;
5186 }
5187
5188
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5189 {
5190 return qe_invalid;
5191 }
5192
5193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version < 2)
5194 {
5195 temp_misc.colors.msgtext = 0x01;
5196 }
5197 else
5198 {
5199
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_misc.colors.msgtext, f))
5200 {
5201 return qe_invalid;
5202 }
5203 }
5204
5205
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if ( s_version >= 3 ) //expanded tile pages to 825
5206 {
5207
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5208 {
5209 return qe_invalid;
5210 }
5211
5212
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5213 {
5214 return qe_invalid;
5215 }
5216
5217
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5218 {
5219 return qe_invalid;
5220 }
5221
5222
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5223 {
5224 return qe_invalid;
5225 }
5226
5227
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5228 {
5229 return qe_invalid;
5230 }
5231
5232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5233 {
5234 return qe_invalid;
5235 }
5236 182 }
5237
5238 387 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5239
5240 387 return 0;
5241 387 }
5242
5243 387 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5244 {
5245 miscQdata temp_misc;
5246 387 word s_version=0;
5247 byte icons;
5248 387 int32_t tempsize=0;
5249
5250 387 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5251
5252 //section version info
5253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
5254 {
5255 return qe_invalid;
5256 }
5257
5258 387 FFCore.quest_format[vIcons] = s_version;
5259
5260
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
5261 {
5262 return qe_invalid;
5263 }
5264
5265
5266 //section size
5267
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&tempsize,f))
5268 {
5269 return qe_invalid;
5270 }
5271
5272 //finally... section data
5273 387 readsize=0;
5274
5275 387 icons=4;
5276
5277
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if ( s_version >= 10 )
5278 {
5279
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<icons; i++)
5280 {
5281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_igetl(&temp_misc.icons[i],f))
5282 {
5283 return qe_invalid;
5284 }
5285 728 }
5286 182 }
5287 else
5288 {
5289
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<icons; i++)
5290 {
5291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_igetw(&temp_misc.icons[i],f))
5292 {
5293 return qe_invalid;
5294 }
5295 820 }
5296 }
5297
5298 387 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5299
5300 387 return 0;
5301 387 }
5302
5303 787 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5304 {
5305
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5306
5307 787 word maxinfos=256;
5308 787 word maxshops=256;
5309 787 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5310 787 word ponds=16, pondsize=72, expansionsize=98*2;
5311 byte tempbyte, padding;
5312 miscQdata temp_misc;
5313 787 word s_version=0;
5314 word swaptmp;
5315 787 int32_t tempsize=0;
5316
5317 787 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5318
5319
2/2
✓ Branch 0 taken 201472 times.
✓ Branch 1 taken 787 times.
202259 for(int32_t i=0; i<maxshops; ++i)
5320 {
5321 201472 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5322 201472 }
5323
5324
2/2
✓ Branch 0 taken 201472 times.
✓ Branch 1 taken 787 times.
202259 for(int32_t i=0; i<maxinfos; ++i)
5325 {
5326 201472 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5327 201472 }
5328
5329 787 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5330
5331
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(Header->zelda_version > 0x192)
5332 {
5333 //section version info
5334
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&s_version,f))
5335 {
5336 return qe_invalid;
5337 }
5338
5339 763 FFCore.quest_format[vMisc] = s_version;
5340
5341
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!read_deprecated_section_cversion(f))
5342 {
5343 return qe_invalid;
5344 }
5345
5346
5347 //section size
5348
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetl(&tempsize,f))
5349 {
5350 return qe_invalid;
5351 }
5352 763 }
5353
5354 //finally... section data
5355 787 readsize=0;
5356
5357 //shops
5358
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(Header->zelda_version > 0x192)
5359 {
5360
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&shops,f))
5361 {
5362 return qe_invalid;
5363 }
5364 763 }
5365
5366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if (shops > NUM_SHOPS)
5367 {
5368 return qe_invalid;
5369 }
5370
5371
2/2
✓ Branch 0 taken 10798 times.
✓ Branch 1 taken 787 times.
11585 for(int32_t i=0; i<shops; i++)
5372 {
5373
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9598 times.
10798 if(s_version > 6)
5374 {
5375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9598 times.
9598 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5376 {
5377 return qe_invalid;
5378 }
5379 9598 }
5380
5381
2/2
✓ Branch 0 taken 32394 times.
✓ Branch 1 taken 10798 times.
43192 for(int32_t j=0; j<3; j++)
5382 {
5383
1/2
✓ Branch 0 taken 32394 times.
✗ Branch 1 not taken.
32394 if(!p_getc(&temp_misc.shop[i].item[j],f))
5384 {
5385 return qe_invalid;
5386 }
5387
5388
2/2
✓ Branch 0 taken 28794 times.
✓ Branch 1 taken 3600 times.
32394 if(s_version < 4)
5389 {
5390 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5391 3600 }
5392 32394 }
5393
5394
2/2
✓ Branch 0 taken 10414 times.
✓ Branch 1 taken 384 times.
10798 if(Header->zelda_version < 0x193)
5395 {
5396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5397 {
5398 return qe_invalid;
5399 }
5400 384 }
5401
5402
2/2
✓ Branch 0 taken 32394 times.
✓ Branch 1 taken 10798 times.
43192 for(int32_t j=0; j<3; j++)
5403 {
5404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32394 times.
32394 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5405 {
5406 return qe_invalid;
5407 }
5408 32394 }
5409
5410
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9598 times.
10798 if(s_version > 3)
5411 {
5412
2/2
✓ Branch 0 taken 28794 times.
✓ Branch 1 taken 9598 times.
38392 for(int32_t j=0; j<3; j++)
5413 {
5414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28794 times.
28794 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5415 return qe_invalid;
5416 28794 }
5417 9598 }
5418
5419 /*
5420 if(s_version < 8)
5421 {
5422 for(int32_t j=0; j<3; j++)
5423 {
5424 (&temp_misc.shop[i].str[j])=0; //initialise.
5425 }
5426 }
5427 */
5428 10798 }
5429
5430 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5431
2/2
✓ Branch 0 taken 201472 times.
✓ Branch 1 taken 787 times.
202259 for(int32_t i=0; i<maxshops; ++i)
5432 {
5433
2/2
✓ Branch 0 taken 402944 times.
✓ Branch 1 taken 201472 times.
604416 for(int32_t j=0; j<3-1; j++)
5434 {
5435
2/2
✓ Branch 0 taken 604416 times.
✓ Branch 1 taken 402944 times.
1007360 for(int32_t k=0; k<2-j; k++)
5436 {
5437
2/2
✓ Branch 0 taken 23434 times.
✓ Branch 1 taken 580982 times.
604416 if(temp_misc.shop[i].hasitem[k]==0)
5438 {
5439 580982 swaptmp = temp_misc.shop[i].item[k];
5440 580982 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5441 580982 temp_misc.shop[i].item[k+1] = swaptmp;
5442 580982 swaptmp = temp_misc.shop[i].price[k];
5443 580982 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5444 580982 temp_misc.shop[i].price[k+1] = swaptmp;
5445 580982 swaptmp = temp_misc.shop[i].hasitem[k];
5446 580982 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5447 580982 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5448 580982 }
5449 604416 }
5450 402944 }
5451 201472 }
5452
5453 //infos
5454
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(Header->zelda_version > 0x192)
5455 {
5456
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&infos,f))
5457 {
5458 return qe_invalid;
5459 }
5460 763 }
5461
5462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if (infos > NUM_INFOS)
5463 {
5464 return qe_invalid;
5465 }
5466
5467
5468
2/2
✓ Branch 0 taken 10104 times.
✓ Branch 1 taken 787 times.
10891 for(int32_t i=0; i<infos; i++)
5469 {
5470
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9343 times.
10104 if(s_version > 6)
5471 {
5472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9343 times.
9343 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5473 {
5474 return qe_invalid;
5475 }
5476 9343 }
5477
5478
2/2
✓ Branch 0 taken 30312 times.
✓ Branch 1 taken 10104 times.
40416 for(int32_t j=0; j<3; j++)
5479 {
5480
3/4
✓ Branch 0 taken 29448 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
30600 if((Header->zelda_version < 0x192)||
5481
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 29160 times.
29448 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5482 {
5483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5484 {
5485 return qe_invalid;
5486 }
5487
5488 864 temp_misc.info[i].str[j]=tempbyte;
5489 864 }
5490 else
5491 {
5492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29448 times.
29448 if(!p_igetw(&temp_misc.info[i].str[j],f))
5493 {
5494 return qe_invalid;
5495 }
5496 }
5497 30312 }
5498
5499
2/2
✓ Branch 0 taken 9720 times.
✓ Branch 1 taken 384 times.
10104 if(Header->zelda_version < 0x193)
5500 {
5501
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5502 {
5503 return qe_invalid;
5504 }
5505 384 }
5506
5507
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10104 if((Header->zelda_version == 0x192)&&(Header->build>145))
5508 {
5509
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5510 {
5511 return qe_invalid;
5512 }
5513 96 }
5514
5515
2/2
✓ Branch 0 taken 30312 times.
✓ Branch 1 taken 10104 times.
40416 for(int32_t j=0; j<3; j++)
5516 {
5517
1/2
✓ Branch 0 taken 30312 times.
✗ Branch 1 not taken.
30312 if(!p_igetw(&temp_misc.info[i].price[j],f))
5518 {
5519 return qe_invalid;
5520 }
5521 30312 }
5522 10104 }
5523
5524 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5525
2/2
✓ Branch 0 taken 201472 times.
✓ Branch 1 taken 787 times.
202259 for(int32_t i=0; i<maxinfos; ++i)
5526 {
5527
2/2
✓ Branch 0 taken 402944 times.
✓ Branch 1 taken 201472 times.
604416 for(int32_t j=0; j<3-1; j++)
5528 {
5529
2/2
✓ Branch 0 taken 604416 times.
✓ Branch 1 taken 402944 times.
1007360 for(int32_t k=0; k<2-j; k++)
5530 {
5531
2/2
✓ Branch 0 taken 11446 times.
✓ Branch 1 taken 592970 times.
604416 if(temp_misc.info[i].str[k]==0)
5532 {
5533 592970 swaptmp = temp_misc.info[i].str[k];
5534 592970 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5535 592970 temp_misc.info[i].str[k+1] = swaptmp;
5536 592970 swaptmp = temp_misc.info[i].price[k];
5537 592970 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5538 592970 temp_misc.info[i].price[k+1] = swaptmp;
5539 592970 }
5540 604416 }
5541 402944 }
5542 201472 }
5543
5544
5545 //warp rings
5546
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 704 times.
787 if(s_version > 5)
5547 704 warprings++;
5548
5549
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(Header->zelda_version > 0x192)
5550 {
5551
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&warprings,f))
5552 {
5553 return qe_invalid;
5554 }
5555
5556
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 433 times.
763 if (warprings > NUM_WARP_RINGS)
5557 {
5558 // return qe_invalid;
5559 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5560 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5561 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5562 433 }
5563 763 }
5564
5565
2/2
✓ Branch 0 taken 8237 times.
✓ Branch 1 taken 787 times.
9024 for(int32_t i=0; i<warprings; i++)
5566 {
5567 // See above comment on the `warprings` range check.
5568 8237 bool keepdata = i < NUM_WARP_RINGS;
5569
5570
2/2
✓ Branch 0 taken 73013 times.
✓ Branch 1 taken 8237 times.
81250 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5571 {
5572
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 64053 times.
73013 if(s_version <= 3)
5573 {
5574
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5575 {
5576 return qe_invalid;
5577 }
5578
5579
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5580 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5581 8960 }
5582 else
5583 {
5584 word tempword;
5585
1/2
✓ Branch 0 taken 64053 times.
✗ Branch 1 not taken.
64053 if(!p_igetw(&tempword,f))
5586 {
5587 return qe_invalid;
5588 }
5589
5590
2/2
✓ Branch 0 taken 7335 times.
✓ Branch 1 taken 56718 times.
64053 if (keepdata)
5591 56718 temp_misc.warp[i].dmap[j] = tempword;
5592 }
5593 73013 }
5594
5595
2/2
✓ Branch 0 taken 73013 times.
✓ Branch 1 taken 8237 times.
81250 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5596 {
5597
1/2
✓ Branch 0 taken 73013 times.
✗ Branch 1 not taken.
73013 if(!p_getc(&tempbyte,f))
5598 {
5599 return qe_invalid;
5600 }
5601
2/2
✓ Branch 0 taken 10527 times.
✓ Branch 1 taken 62486 times.
73013 if (keepdata)
5602 62486 temp_misc.warp[i].scr[j] = tempbyte;
5603 73013 }
5604
5605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8237 times.
8237 if(!p_getc(&tempbyte,f))
5606 {
5607 return qe_invalid;
5608 }
5609
2/2
✓ Branch 0 taken 1214 times.
✓ Branch 1 taken 7023 times.
8237 if (keepdata)
5610 7023 temp_misc.warp[i].size = tempbyte;
5611
5612
2/2
✓ Branch 0 taken 8045 times.
✓ Branch 1 taken 192 times.
8237 if(Header->zelda_version < 0x193)
5613 {
5614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5615 {
5616 return qe_invalid;
5617 }
5618 192 }
5619 8237 }
5620
5621 //palette cycles
5622
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5623 {
5624
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5625 {
5626
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5627 {
5628 18432 temp_misc.cycles[i][j].first=0;
5629 18432 temp_misc.cycles[i][j].count=0;
5630 18432 temp_misc.cycles[i][j].speed=0;
5631 18432 }
5632 6144 }
5633
5634
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5635
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5636 {
5637 18 palcycles=16;
5638 18 }
5639
5640
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5641 {
5642
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5643 {
5644
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5645 {
5646 return qe_invalid;
5647 }
5648
5649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5650 {
5651 return qe_invalid;
5652 }
5653
5654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5655 {
5656 return qe_invalid;
5657 }
5658 5472 }
5659 1824 }
5660 24 }
5661
5662 //Wind warps are now just another warp ring.
5663
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 83 times.
787 if(s_version <= 5)
5664 {
5665
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5666 {
5667
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5668 {
5669 return qe_invalid;
5670 }
5671 59 }
5672
5673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5674 {
5675 return qe_invalid;
5676 }
5677
5678
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5679 {
5680
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5681 {
5682
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5683 {
5684 return qe_invalid;
5685 }
5686
5687 665 temp_misc.warp[8].dmap[i]=tempbyte;
5688 665 }
5689 else
5690 {
5691 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5692 {
5693 return qe_invalid;
5694 }
5695 }
5696
5697
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5698 {
5699 return qe_invalid;
5700 }
5701
5702 665 temp_misc.warp[8].size = 9;
5703
5704
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5705 {
5706 if(!p_getc(&tempbyte,f))
5707 {
5708 return qe_invalid;
5709 }
5710 }
5711 665 }
5712 83 }
5713
5714
5715 //triforce pieces
5716
2/2
✓ Branch 0 taken 6296 times.
✓ Branch 1 taken 787 times.
7083 for(int32_t i=0; i<triforces; i++)
5717 {
5718
1/2
✓ Branch 0 taken 6296 times.
✗ Branch 1 not taken.
6296 if(!p_getc(&temp_misc.triforce[i],f))
5719 {
5720 return qe_invalid;
5721 }
5722 6296 }
5723
5724 //misc color data
5725
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 83 times.
787 if(s_version<3)
5726 {
5727
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5728 {
5729 return qe_invalid;
5730 }
5731
5732
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5733 {
5734 return qe_invalid;
5735 }
5736
5737
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5738 {
5739 return qe_invalid;
5740 }
5741
5742
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5743 {
5744 return qe_invalid;
5745 }
5746
5747
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5748 {
5749 return qe_invalid;
5750 }
5751
5752
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5753 {
5754 return qe_invalid;
5755 }
5756
5757
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5758 {
5759 return qe_invalid;
5760 }
5761
5762
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5763 {
5764 return qe_invalid;
5765 }
5766
5767
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5768 {
5769 return qe_invalid;
5770 }
5771
5772
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5773 {
5774 return qe_invalid;
5775 }
5776
5777
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5778 {
5779 return qe_invalid;
5780 }
5781
5782
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5783 {
5784 return qe_invalid;
5785 }
5786
5787
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5788 {
5789 return qe_invalid;
5790 }
5791
5792
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5793 {
5794 return qe_invalid;
5795 }
5796
5797
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5798 {
5799 return qe_invalid;
5800 }
5801
5802
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5803 {
5804 return qe_invalid;
5805 }
5806
5807
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5808 {
5809 return qe_invalid;
5810 }
5811
5812
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5813 {
5814 return qe_invalid;
5815 }
5816
5817
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5818 {
5819 return qe_invalid;
5820 }
5821
5822
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5823 {
5824 return qe_invalid;
5825 }
5826
5827
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5828 {
5829 return qe_invalid;
5830 }
5831
5832
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5833 {
5834 return qe_invalid;
5835 }
5836
5837
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5838 {
5839 return qe_invalid;
5840 }
5841
5842
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5843 {
5844 return qe_invalid;
5845 }
5846
5847
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5848 {
5849 return qe_invalid;
5850 }
5851
5852
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5853 {
5854 return qe_invalid;
5855 }
5856
5857
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5858 {
5859 return qe_invalid;
5860 }
5861
5862 83 temp_misc.colors.msgtext = 0x01;
5863
5864
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5865 {
5866
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5867 {
5868
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5869 {
5870 return qe_invalid;
5871 }
5872 168 }
5873 24 }
5874
5875
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
5876 {
5877
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
5878 {
5879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
5880 {
5881 return qe_invalid;
5882 }
5883 1536 }
5884 6 }
5885
5886
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
5887 {
5888 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5889 {
5890 return qe_invalid;
5891 }
5892 }
5893
5894 //save game icons
5895
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
5896
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5897 {
5898 18 icons=3;
5899 18 }
5900
5901
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
5902 {
5903
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
5904 {
5905 return qe_invalid;
5906 }
5907 314 }
5908 83 }
5909
5910
3/4
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
793 if((Header->zelda_version < 0x192)||
5911
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 763 times.
769 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5912 {
5913 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5914
5915 18 return 0;
5916 }
5917
5918 //pond information
5919
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 6 times.
769 if(Header->zelda_version < 0x193)
5920 {
5921
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
5922 {
5923 pondsize=25;
5924 }
5925
5926
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
5927 {
5928
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
5929 {
5930
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
5931 {
5932 return qe_invalid;
5933
5934 }
5935 6912 }
5936 96 }
5937 6 }
5938
5939 //end string
5940
2/4
✓ Branch 0 taken 769 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
775 if((Header->zelda_version < 0x192)||
5941
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 763 times.
769 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5942 {
5943 if(!p_getc(&tempbyte,f))
5944 {
5945 return qe_invalid;
5946 }
5947
5948 temp_misc.endstring=tempbyte;
5949
5950 if(!p_getc(&tempbyte,f))
5951 {
5952 return qe_invalid;
5953 }
5954 }
5955 else
5956 {
5957
1/2
✓ Branch 0 taken 769 times.
✗ Branch 1 not taken.
769 if(!p_igetw(&temp_misc.endstring,f))
5958 {
5959 return qe_invalid;
5960 }
5961 }
5962
5963 //expansion
5964
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 6 times.
769 if(Header->zelda_version < 0x193)
5965 {
5966
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
5967 {
5968 expansionsize=99*2;
5969 }
5970
5971
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
5972 {
5973
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
5974 {
5975 return qe_invalid;
5976 }
5977 1176 }
5978 6 }
5979 //shops v8
5980
5981
5982
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 182 times.
769 if(s_version >= 8)
5983 {
5984
2/2
✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 182 times.
2342 for(int32_t i=0; i<shops; i++)
5985 {
5986
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 2160 times.
8640 for(int32_t j=0; j<3; j++)
5987 {
5988
1/2
✓ Branch 0 taken 6480 times.
✗ Branch 1 not taken.
6480 if(!p_igetw(&temp_misc.shop[i].str[j],f))
5989 return qe_invalid;
5990 6480 }
5991 2160 }
5992 182 }
5993
5994 769 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
5995 769 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
5996
5997 //v9 includes quest misc[32]
5998 // ... this has been deprecated (2024)
5999
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 182 times.
769 if(s_version >= 9)
6000 {
6001
2/2
✓ Branch 0 taken 5824 times.
✓ Branch 1 taken 182 times.
6006 for ( int32_t q = 0; q < 32; q++ )
6002 {
6003
1/2
✓ Branch 0 taken 5824 times.
✗ Branch 1 not taken.
5824 if(!p_igetl(&temp_misc.questmisc[q],f))
6004 return qe_invalid;
6005 5824 }
6006 // this was string labels
6007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if (pack_fseek(f, 32 * 128))
6008 return qe_invalid;
6009 182 }
6010
6011
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version >= 11 )
6012 {
6013
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6014 return qe_invalid;
6015 182 }
6016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 587 times.
587 else if(s_version < 11 )
6017 {
6018 587 temp_misc.zscript_last_compiled_version = -1;
6019 587 }
6020
6021 769 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6022
6023
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version >= 12)
6024 {
6025 byte spr;
6026
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t q = 0; q < sprMAX; ++q)
6027 {
6028
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_getc(&spr,f))
6029 return qe_invalid;
6030 46592 temp_misc.sprites[q] = spr;
6031 46592 }
6032 182 }
6033 else
6034 {
6035 587 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6036 //temp_misc.sprites[sprFALL] = ;
6037 }
6038
6039
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version >= 13)
6040 {
6041
2/2
✓ Branch 0 taken 11648 times.
✓ Branch 1 taken 182 times.
11830 for(size_t q = 0; q < 64; ++q)
6042 {
6043 11648 bottletype* bt = &(temp_misc.bottle_types[q]);
6044
1/2
✓ Branch 0 taken 11648 times.
✗ Branch 1 not taken.
11648 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6045 return qe_invalid;
6046
2/2
✓ Branch 0 taken 34944 times.
✓ Branch 1 taken 11648 times.
46592 for(size_t j = 0; j < 3; ++j)
6047 {
6048
1/2
✓ Branch 0 taken 34944 times.
✗ Branch 1 not taken.
34944 if (!p_getc(&(bt->counter[j]), f))
6049 return qe_invalid;
6050
1/2
✓ Branch 0 taken 34944 times.
✗ Branch 1 not taken.
34944 if (!p_igetw(&(bt->amount[j]), f))
6051 return qe_invalid;
6052 34944 }
6053
1/2
✓ Branch 0 taken 11648 times.
✗ Branch 1 not taken.
11648 if (!p_getc(&(bt->flags), f))
6054 return qe_invalid;
6055
1/2
✓ Branch 0 taken 11648 times.
✗ Branch 1 not taken.
11648 if (!p_getc(&(bt->next_type), f))
6056 return qe_invalid;
6057 11648 }
6058
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(size_t q = 0; q < 256; ++q)
6059 {
6060 46592 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6061
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6062 return qe_invalid;
6063
2/2
✓ Branch 0 taken 139776 times.
✓ Branch 1 taken 46592 times.
186368 for(size_t j = 0; j < 3; ++j)
6064 {
6065
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_getc(&(bst->fill[j]), f))
6066 return qe_invalid;
6067
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_igetw(&(bst->comb[j]), f))
6068 return qe_invalid;
6069
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_getc(&(bst->cset[j]), f))
6070 return qe_invalid;
6071
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_igetw(&(bst->price[j]), f))
6072 return qe_invalid;
6073
1/2
✓ Branch 0 taken 139776 times.
✗ Branch 1 not taken.
139776 if (!p_igetw(&(bst->str[j]), f))
6074 return qe_invalid;
6075 139776 }
6076 46592 }
6077 182 }
6078 else
6079 {
6080
2/2
✓ Branch 0 taken 37568 times.
✓ Branch 1 taken 587 times.
38155 for(size_t q = 0; q < 64; ++q)
6081 37568 temp_misc.bottle_types[q].clear();
6082
2/2
✓ Branch 0 taken 150272 times.
✓ Branch 1 taken 587 times.
150859 for(size_t q = 0; q < 256; ++q)
6083 150272 temp_misc.bottle_shop_types[q].clear();
6084 }
6085
6086
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version >= 14)
6087 {
6088 byte msfx;
6089
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t q = 0; q < sfxMAX; ++q)
6090 {
6091
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_getc(&msfx,f))
6092 return qe_invalid;
6093 46592 temp_misc.miscsfx[q] = msfx;
6094 46592 }
6095 182 }
6096 else
6097 {
6098 587 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6099 587 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6100 587 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6101 }
6102
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
769 if(s_version < 15)
6103 {
6104 587 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6105 587 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6106 587 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6107 587 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6108 587 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6109 587 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6110 587 }
6111
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 604 times.
769 if(s_version < 16)
6112 {
6113 604 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6114 604 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6115 604 }
6116
6117
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 768 times.
769 if (!should_skip)
6118 768 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6119
6120 769 return 0;
6121 787 }
6122
6123 extern char *item_string[MAXITEMS];
6124 extern const char *old_item_string[iLast];
6125 extern char *weapon_string[MAXWPNS];
6126 extern const char *old_weapon_string[wLast];
6127
6128 470 int32_t readitems(PACKFILE *f, word version, word build)
6129 {
6130
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6131
6132 byte padding;
6133 int32_t dummy;
6134 470 word items_to_read=MAXITEMS;
6135 470 itemdata tempitem;
6136 470 word s_version=0;
6137 word dummy_word;
6138
6139
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6 times.
470 if(version < 0x186)
6140 {
6141 6 items_to_read=64;
6142 6 }
6143
6144
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 if(version > 0x192)
6145 {
6146 446 items_to_read=0;
6147
6148 //section version info
6149
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&s_version,f))
6150 {
6151 return qe_invalid;
6152 }
6153
6154 446 FFCore.quest_format[vItems] = s_version;
6155
6156
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!read_deprecated_section_cversion(f))
6157 {
6158 return qe_invalid;
6159 }
6160
6161 //section size
6162
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
6163 {
6164 return qe_invalid;
6165 }
6166
6167 //finally... section data
6168
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&items_to_read,f))
6169 {
6170 return qe_invalid;
6171 }
6172
6173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if (items_to_read > MAXITEMS)
6174 {
6175 return qe_invalid;
6176 }
6177 446 }
6178
6179
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 83 times.
470 if(s_version>1)
6180 {
6181
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i=0; i<items_to_read; i++)
6182 {
6183 char tempname[64];
6184
6185
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!pfread(tempname, 64, f))
6186 {
6187 return qe_invalid;
6188 }
6189
6190 99072 item_string[i][0] = '\0';
6191 99072 strncat(item_string[i], tempname, 64 - 1);
6192 99072 }
6193 387 }
6194
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6195 {
6196
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6197 {
6198 20992 reset_itemname(i);
6199 20992 }
6200 82 }
6201
6202
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (!should_skip)
6203
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<MAXITEMS; i++)
6204 {
6205 120064 itemdata& id = itemsbuf[i];
6206 120064 memset(&id, 0, sizeof(itemdata));
6207 120064 id.count=-1;
6208 120064 id.playsound=WAV_SCALE;
6209 120064 reset_itembuf(&id,i);
6210 120533 }
6211
6212
2/2
✓ Branch 0 taken 108194 times.
✓ Branch 1 taken 470 times.
108664 for(int32_t i=0; i<items_to_read; i++)
6213 {
6214 108194 tempitem = itemdata();
6215 108194 reset_itembuf(&tempitem,i);
6216
6217
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 61602 times.
108194 if ( s_version > 35 ) //expanded tiles
6218 {
6219
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.tile,f))
6220 {
6221 return qe_invalid;
6222 }
6223 46592 }
6224 else
6225 {
6226
1/2
✓ Branch 0 taken 61602 times.
✗ Branch 1 not taken.
61602 if(!p_igetw(&tempitem.tile,f))
6227 {
6228 return qe_invalid;
6229 }
6230 }
6231
6232
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.misc_flags,f))
6233 {
6234 return qe_invalid;
6235 }
6236
6237
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.csets,f))
6238 {
6239 return qe_invalid;
6240 }
6241
6242
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.frames,f))
6243 {
6244 return qe_invalid;
6245 }
6246
6247
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.speed,f))
6248 {
6249 return qe_invalid;
6250 }
6251
6252
1/2
✓ Branch 0 taken 108194 times.
✗ Branch 1 not taken.
108194 if(!p_getc(&tempitem.delay,f))
6253 {
6254 return qe_invalid;
6255 }
6256
6257
2/2
✓ Branch 0 taken 103202 times.
✓ Branch 1 taken 4992 times.
108194 if(version < 0x193)
6258 {
6259
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6260 {
6261 return qe_invalid;
6262 }
6263
6264
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6265 {
6266
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6267 256 continue;
6268
6269
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6270 {
6271 case iShield:
6272 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6273 23 break;
6274
6275 case iMShield:
6276 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6277 23 break;
6278
6279 default:
6280 4690 tempitem.ltm=0;
6281 4690 break;
6282 }
6283
6284 4736 tempitem.count=-1;
6285 4736 tempitem.flags=item_none;
6286 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6287 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6288 4736 tempitem.family=0xFF;
6289 4736 tempitem.playsound=WAV_SCALE;
6290 4736 reset_itembuf(&tempitem,i);
6291
6292 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6293
6294 4736 continue;
6295 }
6296 }
6297
6298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103202 times.
103202 if(!p_igetl(&tempitem.ltm,f))
6299 {
6300 return qe_invalid;
6301 }
6302
6303
1/2
✓ Branch 0 taken 103202 times.
✗ Branch 1 not taken.
103202 if(version < 0x193)
6304 {
6305 for(int32_t q=0; q<12; q++)
6306 {
6307 if(!p_getc(&padding,f))
6308 {
6309 return qe_invalid;
6310 }
6311 }
6312 }
6313
6314
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 4130 times.
103202 if(s_version>1)
6315 {
6316
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 52480 times.
99072 if ( s_version >= 31 )
6317 {
6318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.family,f))
6319 {
6320 return qe_invalid;
6321 }
6322 46592 }
6323 else
6324 {
6325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_getc(&tempitem.family,f))
6326 {
6327 return qe_invalid;
6328 }
6329 }
6330
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version < 16)
6331 if(tempitem.family == 0xFF)
6332 tempitem.family = itype_misc;
6333
6334
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.fam_type,f))
6335 {
6336 return qe_invalid;
6337 }
6338
6339
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version>5)
6340 {
6341
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 52480 times.
99072 if(s_version>=31)
6342 {
6343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.power,f))
6344 {
6345 return qe_invalid;
6346 }
6347 46592 }
6348 else
6349 {
6350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(!p_getc(&tempitem.power,f))
6351 {
6352 return qe_invalid;
6353 }
6354 }
6355
6356 //converted flags from 16b to 32b -Z
6357
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version < 41 )
6358 {
6359
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_igetw(&tempitem.flags,f))
6360 {
6361 return qe_invalid;
6362 }
6363 52480 }
6364 else
6365 {
6366
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.flags,f))
6367 {
6368 return qe_invalid;
6369 }
6370 }
6371 99072 }
6372 else
6373 {
6374 //tempitem.power = tempitem.fam_type;
6375 char tempchar;
6376
6377 if(!p_getc(&tempchar,f))
6378 {
6379 return qe_invalid;
6380 }
6381
6382 if (tempchar) tempitem.flags |= item_gamedata;
6383 }
6384
6385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetw(&tempitem.script,f))
6386 {
6387 return qe_invalid;
6388 }
6389
6390
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version<=3)
6391 {
6392 if(tempitem.script > NUMSCRIPTITEM)
6393 {
6394 tempitem.script = 0;
6395 }
6396 }
6397
6398
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.count,f))
6399 {
6400 return qe_invalid;
6401 }
6402
6403
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetw(&tempitem.amount,f))
6404 {
6405 return qe_invalid;
6406 }
6407
6408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetw(&tempitem.collect_script,f))
6409 {
6410 return qe_invalid;
6411 }
6412
6413
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version<=3)
6414 {
6415 if(tempitem.collect_script > NUMSCRIPTITEM)
6416 {
6417 tempitem.collect_script = 0;
6418 }
6419 }
6420
6421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetw(&tempitem.setmax,f))
6422 {
6423 return qe_invalid;
6424 }
6425
6426
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetw(&tempitem.max,f))
6427 {
6428 return qe_invalid;
6429 }
6430
6431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.playsound,f))
6432 {
6433 return qe_invalid;
6434 }
6435
6436
2/2
✓ Branch 0 taken 792576 times.
✓ Branch 1 taken 99072 times.
891648 for(int32_t j=0; j<8; j++)
6437 {
6438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792576 times.
792576 if(!p_igetl(&tempitem.initiald[j],f))
6439 {
6440 return qe_invalid;
6441 }
6442 792576 }
6443
6444
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 99072 times.
297216 for(int32_t j=0; j<2; j++)
6445 {
6446 byte temp;
6447
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&temp,f))
6448 {
6449 return qe_invalid;
6450 }
6451 198144 }
6452
6453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version>4)
6454 {
6455
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version>5)
6456 {
6457
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn,f))
6458 {
6459 return qe_invalid;
6460 }
6461
6462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.wpn2,f))
6463 {
6464 return qe_invalid;
6465 }
6466
6467
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn3,f))
6468 {
6469 return qe_invalid;
6470 }
6471
6472
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn4,f))
6473 {
6474 return qe_invalid;
6475 }
6476
6477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version>=15)
6478 {
6479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.wpn5,f))
6480 {
6481 return qe_invalid;
6482 }
6483
6484
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn6,f))
6485 {
6486 return qe_invalid;
6487 }
6488
6489
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn7,f))
6490 {
6491 return qe_invalid;
6492 }
6493
6494
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn8,f))
6495 {
6496 return qe_invalid;
6497 }
6498
6499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.wpn9,f))
6500 {
6501 return qe_invalid;
6502 }
6503
6504
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.wpn10,f))
6505 {
6506 return qe_invalid;
6507 }
6508 99072 }
6509
6510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_getc(&tempitem.pickup_hearts,f))
6511 {
6512 return qe_invalid;
6513 }
6514
6515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version<15)
6516 {
6517 if(!p_igetw(&dummy_word,f))
6518 {
6519 return qe_invalid;
6520 }
6521
6522 tempitem.misc1=dummy_word;
6523
6524 if(!p_igetw(&dummy_word,f))
6525 {
6526 return qe_invalid;
6527 }
6528
6529 tempitem.misc2=dummy_word;
6530 }
6531 else
6532 {
6533
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc1,f))
6534 {
6535 return qe_invalid;
6536 }
6537
6538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetl(&tempitem.misc2,f))
6539 {
6540 return qe_invalid;
6541 }
6542
6543 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6544
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(s_version<24)
6545 {
6546 if(tempitem.family==itype_shield)
6547 {
6548 tempitem.misc1|=sh_script;
6549 }
6550 }
6551 }
6552
6553
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if(s_version < 53)
6554 {
6555 byte tempbyte;
6556
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_getc(&tempbyte,f))
6557 {
6558 return qe_invalid;
6559 }
6560 52480 tempitem.cost_amount[0] = tempbyte;
6561 52480 }
6562 else
6563 {
6564
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for(auto q = 0; q < 2; ++q)
6565 {
6566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93184 times.
93184 if(!p_igetw(&tempitem.cost_amount[q],f))
6567 {
6568 return qe_invalid;
6569 }
6570 93184 }
6571 }
6572 99072 }
6573 else
6574 {
6575 char tempchar;
6576
6577 if(!p_getc(&tempchar,f))
6578 {
6579 return qe_invalid;
6580 }
6581
6582 if (tempchar) tempitem.flags |= item_edible;
6583 }
6584
6585 // June 2007: more misc. attributes
6586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version>=12)
6587 {
6588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(s_version<15)
6589 {
6590 if(!p_igetw(&dummy_word,f))
6591 {
6592 return qe_invalid;
6593 }
6594
6595 tempitem.misc3=dummy_word;
6596
6597 if(!p_igetw(&dummy_word,f))
6598 {
6599 return qe_invalid;
6600 }
6601
6602 tempitem.misc4=dummy_word;
6603 }
6604 else
6605 {
6606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetl(&tempitem.misc3,f))
6607 {
6608 return qe_invalid;
6609 }
6610
6611
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc4,f))
6612 {
6613 return qe_invalid;
6614 }
6615
6616
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc5,f))
6617 {
6618 return qe_invalid;
6619 }
6620
6621
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc6,f))
6622 {
6623 return qe_invalid;
6624 }
6625
6626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetl(&tempitem.misc7,f))
6627 {
6628 return qe_invalid;
6629 }
6630
6631
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc8,f))
6632 {
6633 return qe_invalid;
6634 }
6635
6636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99072 times.
99072 if(!p_igetl(&tempitem.misc9,f))
6637 {
6638 return qe_invalid;
6639 }
6640
6641
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_igetl(&tempitem.misc10,f))
6642 {
6643 return qe_invalid;
6644 }
6645 }
6646
6647
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!p_getc(&tempitem.usesound,f))
6648 {
6649 return qe_invalid;
6650 }
6651
6652
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 52480 times.
99072 if(s_version >= 49)
6653 {
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_getc(&tempitem.usesound2,f))
6655 {
6656 return qe_invalid;
6657 }
6658 46592 }
6659 52480 else tempitem.usesound2 = 0;
6660
6661
3/4
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
99072 if(s_version < 50 && tempitem.family == itype_mirror)
6662 {
6663 //Split continue/dmap warp effect/sfx, port for old
6664 tempitem.misc2 = tempitem.misc1;
6665 tempitem.usesound2 = tempitem.usesound;
6666 }
6667 99072 }
6668 99072 }
6669
6670
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6671 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_getc(&tempitem.useweapon,f))
6673 {
6674 return qe_invalid;
6675 }
6676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_getc(&tempitem.usedefense,f))
6677 {
6678 return qe_invalid;
6679 }
6680
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weaprange,f))
6681 {
6682 return qe_invalid;
6683 }
6684
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weapduration,f))
6685 {
6686 return qe_invalid;
6687 }
6688
2/2
✓ Branch 0 taken 465920 times.
✓ Branch 1 taken 46592 times.
512512 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6689 {
6690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 465920 times.
465920 if(!p_igetl(&tempitem.weap_pattern[q],f))
6691 {
6692 return qe_invalid;
6693 }
6694 465920 }
6695 46592 }
6696
6697
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6698 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6699
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.duplicates,f))
6700 {
6701 return qe_invalid;
6702 }
6703
2/2
✓ Branch 0 taken 372736 times.
✓ Branch 1 taken 46592 times.
419328 for ( int32_t q = 0; q < INITIAL_D; q++ )
6704 {
6705
1/2
✓ Branch 0 taken 372736 times.
✗ Branch 1 not taken.
372736 if(!p_igetl(&tempitem.weap_initiald[q],f))
6706 {
6707 return qe_invalid;
6708 }
6709 372736 }
6710
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for ( int32_t q = 0; q < 2; q++ )
6711 {
6712 byte temp;
6713
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&temp,f))
6714 {
6715 return qe_invalid;
6716 }
6717 93184 }
6718
6719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_getc(&tempitem.drawlayer,f))
6720 {
6721 return qe_invalid;
6722 }
6723
6724
6725
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.hxofs,f))
6726 {
6727 return qe_invalid;
6728 }
6729
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.hyofs,f))
6730 {
6731 return qe_invalid;
6732 }
6733
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.hxsz,f))
6734 {
6735 return qe_invalid;
6736 }
6737
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.hysz,f))
6738 {
6739 return qe_invalid;
6740 }
6741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.hzsz,f))
6742 {
6743 return qe_invalid;
6744 }
6745
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.xofs,f))
6746 {
6747 return qe_invalid;
6748 }
6749
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.yofs,f))
6750 {
6751 return qe_invalid;
6752 }
6753
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_hxofs,f))
6754 {
6755 return qe_invalid;
6756 }
6757
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_hyofs,f))
6758 {
6759 return qe_invalid;
6760 }
6761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weap_hxsz,f))
6762 {
6763 return qe_invalid;
6764 }
6765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weap_hysz,f))
6766 {
6767 return qe_invalid;
6768 }
6769
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_hzsz,f))
6770 {
6771 return qe_invalid;
6772 }
6773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weap_xofs,f))
6774 {
6775 return qe_invalid;
6776 }
6777
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_yofs,f))
6778 {
6779 return qe_invalid;
6780 }
6781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetw(&tempitem.weaponscript,f))
6782 {
6783 return qe_invalid;
6784 }
6785
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.wpnsprite,f))
6786 {
6787 return qe_invalid;
6788 }
6789 46592 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6790
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for(auto q = 0; q < num_cost_tmr; ++q)
6791 {
6792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93184 times.
93184 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6793 {
6794 return qe_invalid;
6795 }
6796 93184 }
6797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 for(auto q = num_cost_tmr; q < 2; ++q)
6798 tempitem.magiccosttimer[q] = 0;
6799 46592 }
6800
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6801 {
6802 //Item Size FLags, TileWidth, TileHeight
6803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.overrideFLAGS,f))
6804 {
6805 return qe_invalid;
6806 }
6807
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.tilew,f))
6808 {
6809 return qe_invalid;
6810 }
6811
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.tileh,f))
6812 {
6813 return qe_invalid;
6814 }
6815 46592 }
6816
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 29 ) //! More new vars.
6817 {
6818 //Item Size FLags, TileWidth, TileHeight
6819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6820 {
6821 return qe_invalid;
6822 }
6823
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_tilew,f))
6824 {
6825 return qe_invalid;
6826 }
6827
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.weap_tileh,f))
6828 {
6829 return qe_invalid;
6830 }
6831 46592 }
6832
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 30 ) //! More new vars.
6833 {
6834 //Pickup Type
6835
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempitem.pickup,f))
6836 {
6837 return qe_invalid;
6838 }
6839 46592 }
6840
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 32 ) //! More new vars.
6841 {
6842 //Pickup Type
6843
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetw(&tempitem.pstring,f))
6844 {
6845 return qe_invalid;
6846 }
6847 46592 }
6848
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 33 ) //! More new vars.
6849 {
6850 //Pickup Type
6851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(!p_igetw(&tempitem.pickup_string_flags,f))
6852 {
6853 return qe_invalid;
6854 }
6855 46592 }
6856
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 34 ) //! cost counter
6857 {
6858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46592 times.
46592 if(s_version < 53)
6859 {
6860 if(!p_getc(&tempitem.cost_counter[0],f))
6861 {
6862 return qe_invalid;
6863 }
6864 }
6865 else
6866 {
6867
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for(auto q = 0; q < 2; ++q)
6868 {
6869
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&tempitem.cost_counter[q],f))
6870 {
6871 return qe_invalid;
6872 }
6873 93184 }
6874 }
6875 46592 }
6876
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 44 ) //! sprite scripts
6877 {
6878
2/2
✓ Branch 0 taken 372736 times.
✓ Branch 1 taken 46592 times.
419328 for ( int32_t q = 0; q < 8; q++ )
6879 {
6880
2/2
✓ Branch 0 taken 24227840 times.
✓ Branch 1 taken 372736 times.
24600576 for ( int32_t w = 0; w < 65; w++ )
6881 {
6882
1/2
✓ Branch 0 taken 24227840 times.
✗ Branch 1 not taken.
24227840 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6883 {
6884 return qe_invalid;
6885 }
6886 24227840 }
6887
2/2
✓ Branch 0 taken 24227840 times.
✓ Branch 1 taken 372736 times.
24600576 for ( int32_t w = 0; w < 65; w++ )
6888 {
6889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24227840 times.
24227840 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
6890 {
6891 return qe_invalid;
6892 }
6893 24227840 }
6894
2/2
✓ Branch 0 taken 24227840 times.
✓ Branch 1 taken 372736 times.
24600576 for ( int32_t w = 0; w < 65; w++ )
6895 {
6896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24227840 times.
24227840 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
6897 {
6898 return qe_invalid;
6899 }
6900 24227840 }
6901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 372736 times.
372736 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
6902 {
6903 return qe_invalid;
6904 }
6905
6906 372736 }
6907
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 46592 times.
139776 for ( int32_t q = 0; q < 2; q++ )
6908 {
6909 byte temp;
6910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93184 times.
93184 if(!p_getc(&temp,f))
6911 {
6912 return qe_invalid;
6913 }
6914 93184 }
6915 //Pickup Type
6916
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetw(&tempitem.sprite_script,f))
6917 {
6918 return qe_invalid;
6919 }
6920 46592 }
6921
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 46592 times.
99072 if ( s_version >= 48 ) //! pickup flags
6922 {
6923
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_getc(&(tempitem.pickupflag),f))
6924 {
6925 return qe_invalid;
6926 }
6927 46592 }
6928
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 43264 times.
99072 if ( s_version >= 57 )
6929 {
6930 43264 std::string str;
6931
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43264 times.
✓ Branch 2 taken 43264 times.
✗ Branch 3 not taken.
43264 if(!p_getcstr(&str,f))
6932 return qe_invalid;
6933 43264 strncpy(tempitem.display_name,str.c_str(),255);
6934
1/3
✓ Branch 0 taken 43264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
43264 }
6935 99072 }
6936 else
6937 {
6938 4130 tempitem.count=-1;
6939 4130 tempitem.family=itype_misc;
6940 4130 tempitem.flags=item_none;
6941 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6942 4130 tempitem.playsound=WAV_SCALE;
6943 4130 reset_itembuf(&tempitem,i);
6944 }
6945
6946
2/2
✓ Branch 0 taken 60962 times.
✓ Branch 1 taken 42240 times.
103202 if(s_version >= 58)
6947 {
6948
2/2
✓ Branch 0 taken 211200 times.
✓ Branch 1 taken 42240 times.
253440 for(int q = 0; q < WPNSPR_MAX; ++q)
6949 {
6950
1/2
✓ Branch 0 taken 211200 times.
✗ Branch 1 not taken.
211200 if(!p_getc(&tempitem.burnsprs[q],f))
6951 return qe_invalid;
6952
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 209920 times.
211200 if(s_version >= 59)
6953
1/2
✓ Branch 0 taken 209920 times.
✗ Branch 1 not taken.
209920 if(!p_getc(&tempitem.light_rads[q],f))
6954 return qe_invalid;
6955 211200 }
6956 42240 }
6957
6958
2/2
✓ Branch 0 taken 72738 times.
✓ Branch 1 taken 30464 times.
103202 if ( s_version >= 60 )
6959 {
6960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30464 times.
30464 if(!p_getc(&tempitem.pickup_litems,f))
6961 return qe_invalid;
6962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30464 times.
30464 if(!p_igetw(&tempitem.pickup_litem_level,f))
6963 return qe_invalid;
6964 30464 }
6965
6966
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 85282 times.
103202 if ( s_version >= 62 )
6967 {
6968
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if (!p_igetl(&tempitem.moveflags, f))
6969 return qe_invalid;
6970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
17920 if (!p_igetl(&tempitem.wmoveflags, f))
6971 return qe_invalid;
6972 17920 }
6973 else
6974 {
6975 85282 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
6976
2/2
✓ Branch 0 taken 82810 times.
✓ Branch 1 taken 2472 times.
85282 switch(tempitem.family)
6977 {
6978 case itype_bomb:
6979 case itype_sbomb:
6980 case itype_bait:
6981 case itype_liftglove:
6982 case itype_candle:
6983 case itype_book:
6984 2472 tempitem.wmoveflags = (move_obeys_grav | move_can_pitfall);
6985 2472 break;
6986 default:
6987 82810 tempitem.wmoveflags = move_none;
6988 82810 break;
6989 }
6990 }
6991
6992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103202 times.
103202 if (!should_skip)
6993 {
6994
1/2
✓ Branch 0 taken 103202 times.
✗ Branch 1 not taken.
103202 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
6995 {
6996 tempitem.script = 0;
6997 tempitem.weaponscript = 0;
6998 for(int q = 0; q < 8; ++q)
6999 {
7000 tempitem.initiald[q] = 0;
7001 tempitem.weap_initiald[q] = 0;
7002 }
7003 }
7004 103202 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7005 103202 }
7006 103202 }
7007
7008
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (should_skip)
7009 1 return 0;
7010
7011 //////////////////////////////////////////////////////
7012 // Now do any updates because of new item additions
7013 // (These can't be done above because items_to_read
7014 // might be too low.)
7015 //////////////////////////////////////////////////////
7016
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<MAXITEMS; i++)
7017 {
7018 120064 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7019
7020 //Account for older quests that didn't have an actual item for the used letter
7021
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 99072 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
120064 if(s_version < 2 && i==iLetterUsed)
7022 {
7023 82 reset_itembuf(&tempitem, iLetterUsed);
7024 82 strcpy(item_string[i],old_item_string[i]);
7025 82 tempitem.tile = itemsbuf[iLetter].tile;
7026 82 tempitem.csets = itemsbuf[iLetter].csets;
7027 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7028 82 tempitem.frames = itemsbuf[iLetter].frames;
7029 82 tempitem.speed = itemsbuf[iLetter].speed;
7030 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7031 82 }
7032
7033
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 3)
7034 {
7035
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7036 {
7037 case iRocsFeather:
7038 case iHoverBoots:
7039 case iSpinScroll:
7040 case iL2SpinScroll:
7041 case iCrossScroll:
7042 case iQuakeScroll:
7043 case iL2QuakeScroll:
7044 case iWhispRing:
7045 case iL2WhispRing:
7046 case iChargeRing:
7047 case iL2ChargeRing:
7048 case iPerilScroll:
7049 case iWalletL3:
7050 case iQuiverL4:
7051 case iBombBagL4:
7052 case iBracelet:
7053 case iL2Bracelet:
7054 case iOldGlove:
7055 case iL2Ladder:
7056 case iWealthMedal:
7057 case iL2WealthMedal:
7058 case iL3WealthMedal:
7059 1804 reset_itembuf(&tempitem, i);
7060 1804 strcpy(item_string[i],old_item_string[i]);
7061 1804 break;
7062
7063 case iSShield:
7064 82 reset_itembuf(&tempitem, i);
7065 82 strcpy(item_string[i],old_item_string[i]);
7066 82 strcpy(item_string[iShield],old_item_string[iShield]);
7067 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7068 82 break;
7069 }
7070 20992 }
7071
7072
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 5)
7073 {
7074
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7075 {
7076 case iHeartRing:
7077 case iL2HeartRing:
7078 case iL3HeartRing:
7079 case iMagicRing:
7080 case iL2MagicRing:
7081 case iL3MagicRing:
7082 case iL4MagicRing:
7083 574 reset_itembuf(&tempitem, i);
7084 574 strcpy(item_string[i],old_item_string[i]);
7085 574 break;
7086 }
7087 20992 }
7088
7089
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7090 {
7091
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7092
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7093
7094
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 328 times.
✓ Branch 34 taken 17302 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7095 {
7096 case iTriforce:
7097 82 tempitem.fam_type=1;
7098 82 break;
7099
7100 case iBigTri:
7101 82 tempitem.fam_type=0;
7102 82 break;
7103
7104 case iBombs:
7105 82 tempitem.fam_type=i_bomb;
7106 82 tempitem.power=4;
7107 82 tempitem.wpn=wBOMB;
7108 82 tempitem.wpn2=wBOOM;
7109 82 tempitem.misc1 = 50;
7110
7111
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7112
7113 82 break;
7114
7115 case iSBomb:
7116 82 tempitem.fam_type=i_sbomb;
7117 82 tempitem.power=16;
7118 82 tempitem.wpn=wSBOMB;
7119 82 tempitem.wpn2=wSBOOM;
7120 82 tempitem.misc1 = 50;
7121
7122
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7123
7124 82 break;
7125
7126 case iBook:
7127
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7128 tempitem.wpn = wFIREMAGIC;
7129
7130 82 break;
7131
7132 case iSArrow:
7133 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7134 82 tempitem.power=4;
7135 82 tempitem.flags|=item_gamedata;
7136 82 tempitem.wpn=wSARROW;
7137 82 break;
7138
7139 case iGArrow:
7140 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7141 82 tempitem.power=8;
7142 82 tempitem.flags|=(item_gamedata|item_flag1);
7143 82 tempitem.wpn=wGARROW;
7144 82 break;
7145
7146 case iBrang:
7147 82 tempitem.power=0;
7148 82 tempitem.wpn=wBRANG;
7149 82 tempitem.misc1=36;
7150 82 break;
7151
7152 case iMBrang:
7153 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7154 82 tempitem.power=0;
7155 82 tempitem.wpn=wMBRANG;
7156 82 break;
7157
7158 case iFBrang:
7159 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7160 82 tempitem.power=2;
7161 82 tempitem.wpn=wFBRANG;
7162 82 break;
7163
7164 case iBoots:
7165 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7166 82 tempitem.power=7;
7167 82 break;
7168
7169 case iWand:
7170 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7171 82 tempitem.power=2;
7172 82 tempitem.wpn=wWAND;
7173 82 tempitem.wpn3=wMAGIC;
7174 82 break;
7175
7176 case iBCandle:
7177 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7178 82 tempitem.power=1;
7179 82 tempitem.flags|=(item_gamedata|item_flag1);
7180 82 tempitem.wpn3=wFIRE;
7181 82 break;
7182
7183 case iRCandle:
7184 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7185 82 tempitem.power=1;
7186 82 tempitem.wpn3=wFIRE;
7187 82 break;
7188
7189 case iSword:
7190 82 tempitem.power=1;
7191 82 tempitem.flags|= item_flag4 |item_flag2;
7192 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7193 82 tempitem.wpn2=wSWORDSLASH;
7194 82 break;
7195
7196 case iWSword:
7197 82 tempitem.power=2;
7198 82 tempitem.flags|= item_flag4 |item_flag2;
7199 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7200 82 tempitem.wpn2=wWSWORDSLASH;
7201 82 break;
7202
7203 case iMSword:
7204 82 tempitem.power=4;
7205 82 tempitem.flags|= item_flag4 |item_flag2;
7206 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7207 82 tempitem.wpn2=wMSWORDSLASH;
7208 82 break;
7209
7210 case iXSword:
7211 82 tempitem.power=8;
7212 82 tempitem.flags|= item_flag4 |item_flag2;
7213 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7214 82 tempitem.wpn2=wXSWORDSLASH;
7215 82 break;
7216
7217 case iDivineProtection:
7218 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7219 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7220 82 tempitem.wpn=wDIVINEPROTECTION1A;
7221 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7222 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7223 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7224 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7225 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7226 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7227 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7228 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7229 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7230 82 tempitem.misc1=512;
7231 82 tempitem.cost_amount[0]=64;
7232 82 break;
7233
7234 case iLens:
7235 82 tempitem.misc1=60;
7236 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7237 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7238 82 break;
7239
7240 case iArrow:
7241 82 tempitem.power=2;
7242 82 tempitem.wpn=wARROW;
7243 82 break;
7244
7245 case iHoverBoots:
7246 82 tempitem.misc1=45;
7247 82 tempitem.wpn=iwHover;
7248 82 break;
7249
7250 case iDivineFire:
7251 82 tempitem.power=8;
7252 82 tempitem.wpn=wDIVINEFIRE1A;
7253 82 tempitem.wpn2=wDIVINEFIRE1B;
7254 82 tempitem.wpn3=wDIVINEFIRES1A;
7255 82 tempitem.wpn4=wDIVINEFIRES1B;
7256 82 tempitem.misc1 = 32;
7257 82 tempitem.misc2 = 200;
7258 82 tempitem.cost_amount[0]=32;
7259 82 break;
7260
7261 case iDivineEscape:
7262 82 tempitem.cost_amount[0]=32;
7263 82 break;
7264
7265 case iHookshot:
7266 82 tempitem.power=0;
7267 82 tempitem.flags&=~item_flag1;
7268 82 tempitem.wpn=wHSHEAD;
7269 82 tempitem.wpn2=wHSCHAIN_H;
7270 82 tempitem.wpn4=wHSHANDLE;
7271 82 tempitem.wpn3=wHSCHAIN_V;
7272 82 tempitem.misc1=50;
7273 82 tempitem.misc2=100;
7274 82 break;
7275
7276 case iLongshot:
7277 82 tempitem.power=0;
7278 82 tempitem.flags&=~item_flag1;
7279 82 tempitem.wpn=wLSHEAD;
7280 82 tempitem.wpn2=wLSCHAIN_H;
7281 82 tempitem.wpn4=wLSHANDLE;
7282 82 tempitem.wpn3=wLSCHAIN_V;
7283 82 tempitem.misc1=99;
7284 82 tempitem.misc2=100;
7285 82 break;
7286
7287 case iHammer:
7288 82 tempitem.power=4;
7289 82 tempitem.wpn=wHAMMER;
7290 82 tempitem.wpn2=iwHammerSmack;
7291 82 break;
7292
7293 case iCByrna:
7294 82 tempitem.power=1;
7295 82 tempitem.wpn=wCBYRNA;
7296 82 tempitem.wpn2=wCBYRNASLASH;
7297 82 tempitem.wpn3=wCBYRNAORB;
7298 82 tempitem.misc1=4;
7299 82 tempitem.misc2=16;
7300 82 tempitem.misc3=1;
7301 82 tempitem.cost_amount[0]=1;
7302 82 break;
7303
7304 case iWhistle:
7305 82 tempitem.wpn=wWIND;
7306 82 tempitem.misc1=3;
7307 82 tempitem.flags|=item_flag1;
7308 82 break;
7309
7310 case iBRing:
7311 82 tempitem.power=2;
7312 82 tempitem.misc1=spBLUE;
7313 82 break;
7314
7315 case iRRing:
7316 82 tempitem.power=4;
7317 82 tempitem.misc1=spRED;
7318 82 break;
7319
7320 case iGRing:
7321 82 tempitem.power=8;
7322 82 tempitem.misc1=spGOLD;
7323 82 break;
7324
7325 case iSpinScroll:
7326 82 tempitem.power = 2;
7327 82 tempitem.misc1 = 1;
7328 82 break;
7329
7330 case iL2SpinScroll:
7331 82 tempitem.family=itype_spinscroll2;
7332 82 tempitem.fam_type=1;
7333 82 tempitem.cost_amount[0]=8;
7334 82 tempitem.power=2;
7335 82 tempitem.misc1 = 20;
7336 82 break;
7337
7338 case iQuakeScroll:
7339 82 tempitem.misc1=0x10;
7340 82 tempitem.misc2=64;
7341 82 break;
7342
7343 case iL2QuakeScroll:
7344 82 tempitem.family=itype_quakescroll2;
7345 82 tempitem.fam_type=1;
7346 82 tempitem.power = 2;
7347 82 tempitem.misc1=0x20;
7348 82 tempitem.misc2=192;
7349 82 tempitem.cost_amount[0]=8;
7350 82 break;
7351
7352 case iChargeRing:
7353 82 tempitem.misc1=64;
7354 82 tempitem.misc2=128;
7355 82 break;
7356
7357 case iL2ChargeRing:
7358 82 tempitem.misc1=32;
7359 82 tempitem.misc2=64;
7360 82 break;
7361
7362 case iOldGlove:
7363 82 tempitem.flags |= item_flag1;
7364
7365 //fallthrough
7366 case iBombBagL4:
7367 case iWalletL3:
7368 case iQuiverL4:
7369 case iBracelet:
7370 410 tempitem.power = 1;
7371 410 break;
7372
7373 case iL2Bracelet:
7374 82 tempitem.power = 2;
7375 82 break;
7376
7377 case iMKey:
7378 82 tempitem.power=0xFF;
7379 82 tempitem.flags |= item_flag1;
7380 82 break;
7381 }
7382 20992 }
7383
7384
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 7)
7385 {
7386
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7387 {
7388 case iStoneAgony:
7389 case iStompBoots:
7390 case iPerilRing:
7391 case iWhimsicalRing:
7392 {
7393 328 reset_itembuf(&tempitem, i);
7394 328 strcpy(item_string[i],old_item_string[i]);
7395 328 break;
7396 }
7397 }
7398 20992 }
7399
7400
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 8) // May 2007: Some corrections.
7401 {
7402
7/7
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20336 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7403 {
7404 case iMShield:
7405 82 tempitem.misc1|=sh_flame;
7406 82 tempitem.misc2|=sh_fireball|sh_magic;
7407
7408
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7409 {
7410 tempitem.misc2 |= sh_sword;
7411 }
7412
7413 // fallthrough
7414 case iShield:
7415 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7416
7417 // fallthrough
7418 case iSShield:
7419 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7420
7421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7422 {
7423 tempitem.misc2 |= sh_rock;
7424 }
7425
7426 246 break;
7427
7428 case iWhispRing:
7429 82 tempitem.power=1;
7430 82 tempitem.flags|=item_gamedata|item_flag1;
7431 82 tempitem.misc1 = 3;
7432 82 break;
7433
7434 case iL2WhispRing:
7435 82 tempitem.power=0;
7436 82 tempitem.flags|=item_gamedata|item_flag1;
7437 82 tempitem.misc1 = 3;
7438 82 break;
7439
7440 case iL2Ladder:
7441 case iBow:
7442 case iCByrna:
7443 246 tempitem.power = 1;
7444 246 break;
7445 }
7446 20992 }
7447
7448
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 99072 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
120064 if(s_version < 9 && i==iClock)
7449 {
7450 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7451 82 }
7452
7453 //add the misc flag for bomb
7454
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 99072 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
120064 if(s_version < 10 && tempitem.family == itype_bomb)
7455 {
7456 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7457 82 }
7458
7459
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 99072 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
120064 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7460 {
7461 164 tempitem.flags = (tempitem.fam_type ? item_gamedata : item_none);
7462 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7463 164 }
7464
7465
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 12) // June 2007: More Misc. attributes.
7466 {
7467
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7468 {
7469 case iFBrang:
7470 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7471
7472 //fallthrough
7473 case iMBrang:
7474 164 tempitem.misc3 |= sh_sword|sh_magic;
7475
7476 //fallthrough
7477 case iHookshot:
7478 case iLongshot:
7479 //fallthrough
7480 328 tempitem.misc3 |= sh_fireball;
7481
7482 case iBrang:
7483 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7484 410 break;
7485 }
7486
7487
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 246 times.
✓ Branch 6 taken 246 times.
✓ Branch 7 taken 9313 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 328 times.
✓ Branch 14 taken 164 times.
✓ Branch 15 taken 9629 times.
20992 switch(tempitem.family)
7488 {
7489 case itype_hoverboots:
7490 82 tempitem.usesound = WAV_ZN1HOVER;
7491 82 break;
7492
7493 case itype_wand:
7494 82 tempitem.usesound = WAV_WAND;
7495 82 break;
7496
7497 case itype_book:
7498 82 tempitem.usesound = WAV_FIRE;
7499 82 break;
7500
7501 case itype_arrow:
7502 246 tempitem.usesound = WAV_ARROW;
7503 246 break;
7504
7505 case itype_hookshot:
7506 164 tempitem.usesound = WAV_HOOKSHOT;
7507 164 break;
7508
7509 case itype_brang:
7510 246 tempitem.usesound = WAV_BRANG;
7511 246 break;
7512
7513 case itype_shield:
7514 246 tempitem.usesound = WAV_CHINK;
7515 246 break;
7516
7517 case itype_sword:
7518 9313 tempitem.usesound = WAV_SWORD;
7519 9313 break;
7520
7521 case itype_whistle:
7522 82 tempitem.usesound = WAV_WHISTLE;
7523 82 break;
7524
7525 case itype_hammer:
7526 82 tempitem.usesound = WAV_HAMMER;
7527 82 break;
7528
7529 case itype_divinefire:
7530 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7531 82 break;
7532
7533 case itype_divineescape:
7534 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7535 82 break;
7536
7537 case itype_divineprotection:
7538 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7539 82 break;
7540
7541 case itype_bomb:
7542 case itype_sbomb:
7543 case itype_quakescroll:
7544 case itype_quakescroll2:
7545 328 tempitem.usesound = WAV_BOMB;
7546 328 break;
7547
7548 case itype_spinscroll:
7549 case itype_spinscroll2:
7550 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7551 164 break;
7552 }
7553 20992 }
7554
7555
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 13) // July 2007
7556 {
7557
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7558 {
7559 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7560 82 tempitem.power = 1;
7561 82 tempitem.flags|=item_flag1;
7562 82 }
7563
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7564 82 tempitem.flags|=item_flag1;
7565
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7566 {
7567 82 tempitem.flags|=item_flag1;
7568 82 tempitem.power = 2;
7569 82 }
7570 20992 }
7571
7572
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 14) // August 2007
7573 {
7574
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7575 {
7576 164 tempitem.usesound = WAV_SCALE;
7577
7578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 if(tempitem.fam_type)
7579 164 tempitem.misc3=50;
7580 164 }
7581
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7582 {
7583 164 tempitem.flags |= item_gain_old;
7584 164 }
7585 20992 }
7586
7587
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 17) // November 2007
7588 {
7589
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7590 {
7591 tempitem.wpn3 = wFIRE;
7592 }
7593
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7594 {
7595 82 tempitem.flags|=item_flag1;
7596 82 }
7597 20992 }
7598
7599
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 18) // New Year's Eve 2007
7600 {
7601
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7602 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7603
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7604 82 tempitem.misc1 = 768; // Frames until it goes
7605
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7606 {
7607
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7608 {
7609 82 tempitem.misc2 = 1; // Cutscene 1
7610 82 tempitem.flags |= item_flag1; // Side Warp Out
7611 82 }
7612 164 }
7613 20992 }
7614
7615
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 19) // January 2008
7616 {
7617
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7618 {
7619
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 2 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7620
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 10 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7621 82 }
7622 20992 }
7623
7624
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 20) // October 2008
7625 {
7626
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7627 {
7628 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7629 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7630 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7631 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7632 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7633 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7634 82 }
7635 20992 }
7636
7637
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 21) // November 2008
7638 {
7639
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7640 {
7641 tempitem.flags &= ~item_unused;
7642
7643 if(tempitem.family == itype_sword ||
7644 tempitem.family == itype_wand ||
7645 tempitem.family == itype_candle ||
7646 tempitem.family == itype_cbyrna)
7647 {
7648 tempitem.flags |= item_flag4;
7649 }
7650 }
7651 20992 }
7652
7653
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 22) // September 2009
7654 {
7655
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7656 {
7657 164 tempitem.misc3 = tempitem.power/2;
7658 164 }
7659 20992 }
7660
7661
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 23) // March 2011
7662 {
7663
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7664 82 tempitem.wpn5 = wFIRE;
7665
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7666 82 tempitem.wpn2 = wFIRE;
7667 20992 }
7668
7669 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7670 // whether it was or not, and a lot of existing quests depended on the
7671 // incorrect behavior.
7672
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 20992 times.
120064 if(s_version < 25) // January 2012
7673 {
7674
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7675 328 tempitem.flags |= item_flag1;
7676
7677
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7678 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7679 20992 }
7680
7681
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7682 {
7683
60/60
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 568 times.
✓ Branch 2 taken 284 times.
✓ Branch 3 taken 568 times.
✓ Branch 4 taken 1136 times.
✓ Branch 5 taken 284 times.
✓ Branch 6 taken 284 times.
✓ Branch 7 taken 568 times.
✓ Branch 8 taken 311 times.
✓ Branch 9 taken 10996 times.
✓ Branch 10 taken 2923 times.
✓ Branch 11 taken 857 times.
✓ Branch 12 taken 3317 times.
✓ Branch 13 taken 11233 times.
✓ Branch 14 taken 17688 times.
✓ Branch 15 taken 859 times.
✓ Branch 16 taken 844 times.
✓ Branch 17 taken 610 times.
✓ Branch 18 taken 332 times.
✓ Branch 19 taken 287 times.
✓ Branch 20 taken 568 times.
✓ Branch 21 taken 623 times.
✓ Branch 22 taken 302 times.
✓ Branch 23 taken 932 times.
✓ Branch 24 taken 907 times.
✓ Branch 25 taken 565 times.
✓ Branch 26 taken 873 times.
✓ Branch 27 taken 284 times.
✓ Branch 28 taken 300 times.
✓ Branch 29 taken 284 times.
✓ Branch 30 taken 861 times.
✓ Branch 31 taken 287 times.
✓ Branch 32 taken 290 times.
✓ Branch 33 taken 570 times.
✓ Branch 34 taken 260 times.
✓ Branch 35 taken 287 times.
✓ Branch 36 taken 284 times.
✓ Branch 37 taken 284 times.
✓ Branch 38 taken 300 times.
✓ Branch 39 taken 286 times.
✓ Branch 40 taken 287 times.
✓ Branch 41 taken 284 times.
✓ Branch 42 taken 289 times.
✓ Branch 43 taken 785 times.
✓ Branch 44 taken 284 times.
✓ Branch 45 taken 555 times.
✓ Branch 46 taken 1136 times.
✓ Branch 47 taken 284 times.
✓ Branch 48 taken 284 times.
✓ Branch 49 taken 284 times.
✓ Branch 50 taken 571 times.
✓ Branch 51 taken 284 times.
✓ Branch 52 taken 855 times.
✓ Branch 53 taken 858 times.
✓ Branch 54 taken 1148 times.
✓ Branch 55 taken 284 times.
✓ Branch 56 taken 284 times.
✓ Branch 57 taken 284 times.
✓ Branch 58 taken 284 times.
✓ Branch 59 taken 284 times.
73472 switch(tempitem.family)
7684 {
7685 case itype_sword:
7686 {
7687 17688 tempitem.flags &= ~(item_flag5);
7688 17688 tempitem.misc3 = 0;
7689 17688 tempitem.misc4 = 0;
7690 17688 tempitem.misc5 = 0;
7691 17688 tempitem.misc6 = 0;
7692 17688 tempitem.misc7 = 0;
7693 17688 tempitem.misc8 = 0;
7694 17688 tempitem.misc9 = 0;
7695 17688 tempitem.misc10 = 0;
7696 17688 tempitem.wpn4 = 0;
7697 17688 tempitem.wpn5 = 0;
7698 17688 tempitem.wpn6 = 0;
7699 17688 tempitem.wpn7 = 0;
7700 17688 tempitem.wpn8 = 0;
7701 17688 tempitem.wpn9 = 0;
7702 17688 tempitem.wpn10 = 0;
7703 17688 break;
7704 }
7705 case itype_brang:
7706 {
7707 859 tempitem.flags &= ~(item_flag4 | item_flag5);
7708 859 tempitem.misc2 = 0;
7709 859 tempitem.misc5 = 0;
7710 859 tempitem.misc6 = 0;
7711 859 tempitem.misc7 = 0;
7712 859 tempitem.misc8 = 0;
7713 859 tempitem.misc9 = 0;
7714 859 tempitem.misc10 = 0;
7715 859 tempitem.wpn4 = 0;
7716 859 tempitem.wpn5 = 0;
7717 859 tempitem.wpn6 = 0;
7718 859 tempitem.wpn7 = 0;
7719 859 tempitem.wpn8 = 0;
7720 859 tempitem.wpn9 = 0;
7721 859 tempitem.wpn10 = 0;
7722 859 break;
7723 }
7724 case itype_arrow:
7725 {
7726 844 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7727 844 tempitem.misc2 = 0;
7728 844 tempitem.misc3 = 0;
7729 844 tempitem.misc4 = 0;
7730 844 tempitem.misc5 = 0;
7731 844 tempitem.misc6 = 0;
7732 844 tempitem.misc7 = 0;
7733 844 tempitem.misc8 = 0;
7734 844 tempitem.misc9 = 0;
7735 844 tempitem.misc10 = 0;
7736 844 tempitem.wpn4 = 0;
7737 844 tempitem.wpn5 = 0;
7738 844 tempitem.wpn6 = 0;
7739 844 tempitem.wpn7 = 0;
7740 844 tempitem.wpn8 = 0;
7741 844 tempitem.wpn9 = 0;
7742 844 tempitem.wpn10 = 0;
7743 844 break;
7744 }
7745 case itype_candle:
7746 {
7747 610 tempitem.flags &= ~ (item_flag3 | item_flag5);
7748 610 tempitem.misc1 = 0;
7749 610 tempitem.misc2 = 0;
7750 610 tempitem.misc3 = 0;
7751 610 tempitem.misc4 = 0;
7752 610 tempitem.misc5 = 0;
7753 610 tempitem.misc6 = 0;
7754 610 tempitem.misc7 = 0;
7755 610 tempitem.misc8 = 0;
7756 610 tempitem.misc9 = 0;
7757 610 tempitem.misc10 = 0;
7758 610 tempitem.wpn4 = 0;
7759 610 tempitem.wpn5 = 0;
7760 610 tempitem.wpn6 = 0;
7761 610 tempitem.wpn7 = 0;
7762 610 tempitem.wpn8 = 0;
7763 610 tempitem.wpn9 = 0;
7764 610 tempitem.wpn10 = 0;
7765 610 break;
7766 }
7767 case itype_whistle:
7768 {
7769 332 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7770 332 tempitem.misc3 = 0;
7771 332 tempitem.misc4 = 0;
7772 332 tempitem.misc5 = 0;
7773 332 tempitem.misc6 = 0;
7774 332 tempitem.misc7 = 0;
7775 332 tempitem.misc8 = 0;
7776 332 tempitem.misc9 = 0;
7777 332 tempitem.misc10 = 0;
7778 332 tempitem.wpn2 = 0;
7779 332 tempitem.wpn3 = 0;
7780 332 tempitem.wpn4 = 0;
7781 332 tempitem.wpn5 = 0;
7782 332 tempitem.wpn6 = 0;
7783 332 tempitem.wpn7 = 0;
7784 332 tempitem.wpn8 = 0;
7785 332 tempitem.wpn9 = 0;
7786 332 tempitem.wpn10 = 0;
7787 332 break;
7788 }
7789 case itype_bait:
7790 {
7791 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7792 287 tempitem.misc2 = 0;
7793 287 tempitem.misc3 = 0;
7794 287 tempitem.misc4 = 0;
7795 287 tempitem.misc5 = 0;
7796 287 tempitem.misc6 = 0;
7797 287 tempitem.misc7 = 0;
7798 287 tempitem.misc8 = 0;
7799 287 tempitem.misc9 = 0;
7800 287 tempitem.misc10 = 0;
7801 287 tempitem.wpn2 = 0;
7802 287 tempitem.wpn3 = 0;
7803 287 tempitem.wpn4 = 0;
7804 287 tempitem.wpn5 = 0;
7805 287 tempitem.wpn6 = 0;
7806 287 tempitem.wpn7 = 0;
7807 287 tempitem.wpn8 = 0;
7808 287 tempitem.wpn9 = 0;
7809 287 tempitem.wpn10 = 0;
7810 287 break;
7811 }
7812 case itype_letter:
7813 {
7814 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7815 568 tempitem.misc1 = 0;
7816 568 tempitem.misc2 = 0;
7817 568 tempitem.misc3 = 0;
7818 568 tempitem.misc4 = 0;
7819 568 tempitem.misc5 = 0;
7820 568 tempitem.misc6 = 0;
7821 568 tempitem.misc7 = 0;
7822 568 tempitem.misc8 = 0;
7823 568 tempitem.misc9 = 0;
7824 568 tempitem.misc10 = 0;
7825 568 tempitem.wpn = 0;
7826 568 tempitem.wpn2 = 0;
7827 568 tempitem.wpn3 = 0;
7828 568 tempitem.wpn4 = 0;
7829 568 tempitem.wpn5 = 0;
7830 568 tempitem.wpn6 = 0;
7831 568 tempitem.wpn7 = 0;
7832 568 tempitem.wpn8 = 0;
7833 568 tempitem.wpn9 = 0;
7834 568 tempitem.wpn10 = 0;
7835 568 break;
7836 }
7837 case itype_potion:
7838 {
7839 623 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7840 623 tempitem.misc3 = 0;
7841 623 tempitem.misc4 = 0;
7842 623 tempitem.misc5 = 0;
7843 623 tempitem.misc6 = 0;
7844 623 tempitem.misc7 = 0;
7845 623 tempitem.misc8 = 0;
7846 623 tempitem.misc9 = 0;
7847 623 tempitem.misc10 = 0;
7848 623 tempitem.wpn = 0;
7849 623 tempitem.wpn2 = 0;
7850 623 tempitem.wpn3 = 0;
7851 623 tempitem.wpn4 = 0;
7852 623 tempitem.wpn5 = 0;
7853 623 tempitem.wpn6 = 0;
7854 623 tempitem.wpn7 = 0;
7855 623 tempitem.wpn8 = 0;
7856 623 tempitem.wpn9 = 0;
7857 623 tempitem.wpn10 = 0;
7858 623 break;
7859 }
7860 case itype_wand:
7861 {
7862 302 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
7863 302 tempitem.misc1 = 0;
7864 302 tempitem.misc2 = 0;
7865 302 tempitem.misc3 = 0;
7866 302 tempitem.misc4 = 0;
7867 302 tempitem.misc5 = 0;
7868 302 tempitem.misc6 = 0;
7869 302 tempitem.misc7 = 0;
7870 302 tempitem.misc8 = 0;
7871 302 tempitem.misc9 = 0;
7872 302 tempitem.misc10 = 0;
7873 302 tempitem.wpn4 = 0;
7874 302 tempitem.wpn5 = 0;
7875 302 tempitem.wpn6 = 0;
7876 302 tempitem.wpn7 = 0;
7877 302 tempitem.wpn8 = 0;
7878 302 tempitem.wpn9 = 0;
7879 302 tempitem.wpn10 = 0;
7880 302 break;
7881 }
7882 case itype_ring:
7883 {
7884 932 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7885 932 tempitem.misc2 = 0;
7886 932 tempitem.misc3 = 0;
7887 932 tempitem.misc4 = 0;
7888 932 tempitem.misc5 = 0;
7889 932 tempitem.misc6 = 0;
7890 932 tempitem.misc7 = 0;
7891 932 tempitem.misc8 = 0;
7892 932 tempitem.misc9 = 0;
7893 932 tempitem.misc10 = 0;
7894 932 tempitem.wpn = 0;
7895 932 tempitem.wpn2 = 0;
7896 932 tempitem.wpn3 = 0;
7897 932 tempitem.wpn4 = 0;
7898 932 tempitem.wpn5 = 0;
7899 932 tempitem.wpn6 = 0;
7900 932 tempitem.wpn7 = 0;
7901 932 tempitem.wpn8 = 0;
7902 932 tempitem.wpn9 = 0;
7903 932 tempitem.wpn10 = 0;
7904 932 break;
7905 }
7906 case itype_wallet:
7907 {
7908 907 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7909 907 tempitem.misc3 = 0;
7910 907 tempitem.misc4 = 0;
7911 907 tempitem.misc5 = 0;
7912 907 tempitem.misc6 = 0;
7913 907 tempitem.misc7 = 0;
7914 907 tempitem.misc8 = 0;
7915 907 tempitem.misc9 = 0;
7916 907 tempitem.misc10 = 0;
7917 907 tempitem.wpn = 0;
7918 907 tempitem.wpn2 = 0;
7919 907 tempitem.wpn3 = 0;
7920 907 tempitem.wpn4 = 0;
7921 907 tempitem.wpn5 = 0;
7922 907 tempitem.wpn6 = 0;
7923 907 tempitem.wpn7 = 0;
7924 907 tempitem.wpn8 = 0;
7925 907 tempitem.wpn9 = 0;
7926 907 tempitem.wpn10 = 0;
7927 907 break;
7928 }
7929 case itype_amulet:
7930 {
7931 565 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7932 565 tempitem.misc1 = 0;
7933 565 tempitem.misc2 = 0;
7934 565 tempitem.misc3 = 0;
7935 565 tempitem.misc4 = 0;
7936 565 tempitem.misc5 = 0;
7937 565 tempitem.misc6 = 0;
7938 565 tempitem.misc7 = 0;
7939 565 tempitem.misc8 = 0;
7940 565 tempitem.misc9 = 0;
7941 565 tempitem.misc10 = 0;
7942 565 tempitem.wpn = 0;
7943 565 tempitem.wpn2 = 0;
7944 565 tempitem.wpn3 = 0;
7945 565 tempitem.wpn4 = 0;
7946 565 tempitem.wpn5 = 0;
7947 565 tempitem.wpn6 = 0;
7948 565 tempitem.wpn7 = 0;
7949 565 tempitem.wpn8 = 0;
7950 565 tempitem.wpn9 = 0;
7951 565 tempitem.wpn10 = 0;
7952 565 break;
7953 }
7954 case itype_shield:
7955 {
7956 873 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7957 873 tempitem.misc3 = 0;
7958 873 tempitem.misc4 = 0;
7959 873 tempitem.misc5 = 0;
7960 873 tempitem.misc6 = 0;
7961 873 tempitem.misc7 = 0;
7962 873 tempitem.misc8 = 0;
7963 873 tempitem.misc9 = 0;
7964 873 tempitem.misc10 = 0;
7965 873 tempitem.wpn = 0;
7966 873 tempitem.wpn2 = 0;
7967 873 tempitem.wpn3 = 0;
7968 873 tempitem.wpn4 = 0;
7969 873 tempitem.wpn5 = 0;
7970 873 tempitem.wpn6 = 0;
7971 873 tempitem.wpn7 = 0;
7972 873 tempitem.wpn8 = 0;
7973 873 tempitem.wpn9 = 0;
7974 873 tempitem.wpn10 = 0;
7975 873 break;
7976 }
7977 case itype_bow:
7978 {
7979 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7980 568 tempitem.misc1 = 0;
7981 568 tempitem.misc2 = 0;
7982 568 tempitem.misc3 = 0;
7983 568 tempitem.misc4 = 0;
7984 568 tempitem.misc5 = 0;
7985 568 tempitem.misc6 = 0;
7986 568 tempitem.misc7 = 0;
7987 568 tempitem.misc8 = 0;
7988 568 tempitem.misc9 = 0;
7989 568 tempitem.misc10 = 0;
7990 568 tempitem.wpn = 0;
7991 568 tempitem.wpn2 = 0;
7992 568 tempitem.wpn3 = 0;
7993 568 tempitem.wpn4 = 0;
7994 568 tempitem.wpn5 = 0;
7995 568 tempitem.wpn6 = 0;
7996 568 tempitem.wpn7 = 0;
7997 568 tempitem.wpn8 = 0;
7998 568 tempitem.wpn9 = 0;
7999 568 tempitem.wpn10 = 0;
8000 568 break;
8001 }
8002 case itype_raft:
8003 {
8004 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8005 284 tempitem.misc1 = 0;
8006 284 tempitem.misc2 = 0;
8007 284 tempitem.misc3 = 0;
8008 284 tempitem.misc4 = 0;
8009 284 tempitem.misc5 = 0;
8010 284 tempitem.misc6 = 0;
8011 284 tempitem.misc7 = 0;
8012 284 tempitem.misc8 = 0;
8013 284 tempitem.misc9 = 0;
8014 284 tempitem.misc10 = 0;
8015 284 tempitem.wpn = 0;
8016 284 tempitem.wpn2 = 0;
8017 284 tempitem.wpn3 = 0;
8018 284 tempitem.wpn4 = 0;
8019 284 tempitem.wpn5 = 0;
8020 284 tempitem.wpn6 = 0;
8021 284 tempitem.wpn7 = 0;
8022 284 tempitem.wpn8 = 0;
8023 284 tempitem.wpn9 = 0;
8024 284 tempitem.wpn10 = 0;
8025 284 break;
8026 }
8027 case itype_ladder:
8028 {
8029 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8030 568 tempitem.misc1 = 0;
8031 568 tempitem.misc2 = 0;
8032 568 tempitem.misc3 = 0;
8033 568 tempitem.misc4 = 0;
8034 568 tempitem.misc5 = 0;
8035 568 tempitem.misc6 = 0;
8036 568 tempitem.misc7 = 0;
8037 568 tempitem.misc8 = 0;
8038 568 tempitem.misc9 = 0;
8039 568 tempitem.misc10 = 0;
8040 568 tempitem.wpn = 0;
8041 568 tempitem.wpn2 = 0;
8042 568 tempitem.wpn3 = 0;
8043 568 tempitem.wpn4 = 0;
8044 568 tempitem.wpn5 = 0;
8045 568 tempitem.wpn6 = 0;
8046 568 tempitem.wpn7 = 0;
8047 568 tempitem.wpn8 = 0;
8048 568 tempitem.wpn9 = 0;
8049 568 tempitem.wpn10 = 0;
8050 568 break;
8051 }
8052 case itype_book:
8053 {
8054 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8055 300 tempitem.misc1 = 0;
8056 300 tempitem.misc2 = 0;
8057 300 tempitem.misc3 = 0;
8058 300 tempitem.misc4 = 0;
8059 300 tempitem.misc5 = 0;
8060 300 tempitem.misc6 = 0;
8061 300 tempitem.misc7 = 0;
8062 300 tempitem.misc8 = 0;
8063 300 tempitem.misc9 = 0;
8064 300 tempitem.misc10 = 0;
8065 300 tempitem.wpn3 = 0;
8066 300 tempitem.wpn4 = 0;
8067 300 tempitem.wpn5 = 0;
8068 300 tempitem.wpn6 = 0;
8069 300 tempitem.wpn7 = 0;
8070 300 tempitem.wpn8 = 0;
8071 300 tempitem.wpn9 = 0;
8072 300 tempitem.wpn10 = 0;
8073 300 break;
8074 }
8075 case itype_magickey:
8076 {
8077 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8078 284 tempitem.misc1 = 0;
8079 284 tempitem.misc2 = 0;
8080 284 tempitem.misc3 = 0;
8081 284 tempitem.misc4 = 0;
8082 284 tempitem.misc5 = 0;
8083 284 tempitem.misc6 = 0;
8084 284 tempitem.misc7 = 0;
8085 284 tempitem.misc8 = 0;
8086 284 tempitem.misc9 = 0;
8087 284 tempitem.misc10 = 0;
8088 284 tempitem.wpn = 0;
8089 284 tempitem.wpn2 = 0;
8090 284 tempitem.wpn3 = 0;
8091 284 tempitem.wpn4 = 0;
8092 284 tempitem.wpn5 = 0;
8093 284 tempitem.wpn6 = 0;
8094 284 tempitem.wpn7 = 0;
8095 284 tempitem.wpn8 = 0;
8096 284 tempitem.wpn9 = 0;
8097 284 tempitem.wpn10 = 0;
8098 284 break;
8099 }
8100 case itype_bracelet:
8101 {
8102 861 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8103 861 tempitem.misc1 = 0;
8104 861 tempitem.misc2 = 0;
8105 861 tempitem.misc3 = 0;
8106 861 tempitem.misc4 = 0;
8107 861 tempitem.misc5 = 0;
8108 861 tempitem.misc6 = 0;
8109 861 tempitem.misc7 = 0;
8110 861 tempitem.misc8 = 0;
8111 861 tempitem.misc9 = 0;
8112 861 tempitem.misc10 = 0;
8113 861 tempitem.wpn = 0;
8114 861 tempitem.wpn2 = 0;
8115 861 tempitem.wpn3 = 0;
8116 861 tempitem.wpn4 = 0;
8117 861 tempitem.wpn5 = 0;
8118 861 tempitem.wpn6 = 0;
8119 861 tempitem.wpn7 = 0;
8120 861 tempitem.wpn8 = 0;
8121 861 tempitem.wpn9 = 0;
8122 861 tempitem.wpn10 = 0;
8123 861 break;
8124 }
8125 case itype_flippers:
8126 {
8127 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8128 287 tempitem.misc1 = 0;
8129 287 tempitem.misc2 = 0;
8130 287 tempitem.misc3 = 0;
8131 287 tempitem.misc4 = 0;
8132 287 tempitem.misc5 = 0;
8133 287 tempitem.misc6 = 0;
8134 287 tempitem.misc7 = 0;
8135 287 tempitem.misc8 = 0;
8136 287 tempitem.misc9 = 0;
8137 287 tempitem.misc10 = 0;
8138 287 tempitem.wpn = 0;
8139 287 tempitem.wpn2 = 0;
8140 287 tempitem.wpn3 = 0;
8141 287 tempitem.wpn4 = 0;
8142 287 tempitem.wpn5 = 0;
8143 287 tempitem.wpn6 = 0;
8144 287 tempitem.wpn7 = 0;
8145 287 tempitem.wpn8 = 0;
8146 287 tempitem.wpn9 = 0;
8147 287 tempitem.wpn10 = 0;
8148 287 break;
8149 }
8150 case itype_boots:
8151 {
8152 290 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8153 290 tempitem.misc1 = 0;
8154 290 tempitem.misc2 = 0;
8155 290 tempitem.misc3 = 0;
8156 290 tempitem.misc4 = 0;
8157 290 tempitem.misc5 = 0;
8158 290 tempitem.misc6 = 0;
8159 290 tempitem.misc7 = 0;
8160 290 tempitem.misc8 = 0;
8161 290 tempitem.misc9 = 0;
8162 290 tempitem.misc10 = 0;
8163 290 tempitem.wpn = 0;
8164 290 tempitem.wpn2 = 0;
8165 290 tempitem.wpn3 = 0;
8166 290 tempitem.wpn4 = 0;
8167 290 tempitem.wpn5 = 0;
8168 290 tempitem.wpn6 = 0;
8169 290 tempitem.wpn7 = 0;
8170 290 tempitem.wpn8 = 0;
8171 290 tempitem.wpn9 = 0;
8172 290 tempitem.wpn10 = 0;
8173 290 break;
8174 }
8175 case itype_hookshot:
8176 {
8177 570 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8178 570 tempitem.misc5 = 0;
8179 570 tempitem.misc6 = 0;
8180 570 tempitem.misc7 = 0;
8181 570 tempitem.misc8 = 0;
8182 570 tempitem.misc9 = 0;
8183 570 tempitem.misc10 = 0;
8184 570 tempitem.wpn5 = 0;
8185 570 tempitem.wpn6 = 0;
8186 570 tempitem.wpn7 = 0;
8187 570 tempitem.wpn8 = 0;
8188 570 tempitem.wpn9 = 0;
8189 570 tempitem.wpn10 = 0;
8190 570 break;
8191 }
8192 case itype_lens:
8193 {
8194 260 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8195 260 tempitem.misc2 = 0;
8196 260 tempitem.misc3 = 0;
8197 260 tempitem.misc4 = 0;
8198 260 tempitem.misc5 = 0;
8199 260 tempitem.misc6 = 0;
8200 260 tempitem.misc7 = 0;
8201 260 tempitem.misc8 = 0;
8202 260 tempitem.misc9 = 0;
8203 260 tempitem.misc10 = 0;
8204 260 tempitem.wpn = 0;
8205 260 tempitem.wpn2 = 0;
8206 260 tempitem.wpn3 = 0;
8207 260 tempitem.wpn4 = 0;
8208 260 tempitem.wpn5 = 0;
8209 260 tempitem.wpn6 = 0;
8210 260 tempitem.wpn7 = 0;
8211 260 tempitem.wpn8 = 0;
8212 260 tempitem.wpn9 = 0;
8213 260 tempitem.wpn10 = 0;
8214 260 break;
8215 }
8216 case itype_hammer:
8217 {
8218 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8219 287 tempitem.misc1 = 0;
8220 287 tempitem.misc2 = 0;
8221 287 tempitem.misc3 = 0;
8222 287 tempitem.misc4 = 0;
8223 287 tempitem.misc5 = 0;
8224 287 tempitem.misc6 = 0;
8225 287 tempitem.misc7 = 0;
8226 287 tempitem.misc8 = 0;
8227 287 tempitem.misc9 = 0;
8228 287 tempitem.misc10 = 0;
8229 287 tempitem.wpn3 = 0;
8230 287 tempitem.wpn4 = 0;
8231 287 tempitem.wpn5 = 0;
8232 287 tempitem.wpn6 = 0;
8233 287 tempitem.wpn7 = 0;
8234 287 tempitem.wpn8 = 0;
8235 287 tempitem.wpn9 = 0;
8236 287 tempitem.wpn10 = 0;
8237 287 break;
8238 }
8239 case itype_divinefire:
8240 {
8241 284 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8242 284 tempitem.misc3 = 0;
8243 284 tempitem.misc4 = 0;
8244 284 tempitem.misc5 = 0;
8245 284 tempitem.misc6 = 0;
8246 284 tempitem.misc7 = 0;
8247 284 tempitem.misc8 = 0;
8248 284 tempitem.misc9 = 0;
8249 284 tempitem.misc10 = 0;
8250 284 tempitem.wpn6 = 0;
8251 284 tempitem.wpn7 = 0;
8252 284 tempitem.wpn8 = 0;
8253 284 tempitem.wpn9 = 0;
8254 284 tempitem.wpn10 = 0;
8255 284 break;
8256 }
8257 case itype_divineescape:
8258 {
8259 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8260 284 tempitem.misc2 = 0;
8261 284 tempitem.misc3 = 0;
8262 284 tempitem.misc4 = 0;
8263 284 tempitem.misc5 = 0;
8264 284 tempitem.misc6 = 0;
8265 284 tempitem.misc7 = 0;
8266 284 tempitem.misc8 = 0;
8267 284 tempitem.misc9 = 0;
8268 284 tempitem.misc10 = 0;
8269 284 tempitem.wpn = 0;
8270 284 tempitem.wpn2 = 0;
8271 284 tempitem.wpn3 = 0;
8272 284 tempitem.wpn4 = 0;
8273 284 tempitem.wpn5 = 0;
8274 284 tempitem.wpn6 = 0;
8275 284 tempitem.wpn7 = 0;
8276 284 tempitem.wpn8 = 0;
8277 284 tempitem.wpn9 = 0;
8278 284 tempitem.wpn10 = 0;
8279 284 break;
8280 }
8281 case itype_divineprotection:
8282 {
8283 284 tempitem.flags &= ~ (item_flag5);
8284 284 tempitem.misc2 = 0;
8285 284 tempitem.misc3 = 0;
8286 284 tempitem.misc4 = 0;
8287 284 tempitem.misc5 = 0;
8288 284 tempitem.misc6 = 0;
8289 284 tempitem.misc7 = 0;
8290 284 tempitem.misc8 = 0;
8291 284 tempitem.misc9 = 0;
8292 284 tempitem.misc10 = 0;
8293 284 break;
8294 }
8295 case itype_bomb:
8296 {
8297 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8298 300 tempitem.misc4 = 0;
8299 300 tempitem.misc5 = 0;
8300 300 tempitem.misc6 = 0;
8301 300 tempitem.misc7 = 0;
8302 300 tempitem.misc8 = 0;
8303 300 tempitem.misc9 = 0;
8304 300 tempitem.misc10 = 0;
8305 300 tempitem.wpn3 = 0;
8306 300 tempitem.wpn4 = 0;
8307 300 tempitem.wpn5 = 0;
8308 300 tempitem.wpn6 = 0;
8309 300 tempitem.wpn7 = 0;
8310 300 tempitem.wpn8 = 0;
8311 300 tempitem.wpn9 = 0;
8312 300 tempitem.wpn10 = 0;
8313 300 break;
8314 }
8315 case itype_sbomb:
8316 {
8317 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8318 286 tempitem.misc4 = 0;
8319 286 tempitem.misc5 = 0;
8320 286 tempitem.misc6 = 0;
8321 286 tempitem.misc7 = 0;
8322 286 tempitem.misc8 = 0;
8323 286 tempitem.misc9 = 0;
8324 286 tempitem.misc10 = 0;
8325 286 tempitem.wpn3 = 0;
8326 286 tempitem.wpn4 = 0;
8327 286 tempitem.wpn5 = 0;
8328 286 tempitem.wpn6 = 0;
8329 286 tempitem.wpn7 = 0;
8330 286 tempitem.wpn8 = 0;
8331 286 tempitem.wpn9 = 0;
8332 286 tempitem.wpn10 = 0;
8333 286 break;
8334 }
8335 case itype_clock:
8336 {
8337 287 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8338 287 tempitem.misc2 = 0;
8339 287 tempitem.misc3 = 0;
8340 287 tempitem.misc4 = 0;
8341 287 tempitem.misc5 = 0;
8342 287 tempitem.misc6 = 0;
8343 287 tempitem.misc7 = 0;
8344 287 tempitem.misc8 = 0;
8345 287 tempitem.misc9 = 0;
8346 287 tempitem.misc10 = 0;
8347 287 tempitem.wpn = 0;
8348 287 tempitem.wpn2 = 0;
8349 287 tempitem.wpn3 = 0;
8350 287 tempitem.wpn4 = 0;
8351 287 tempitem.wpn5 = 0;
8352 287 tempitem.wpn6 = 0;
8353 287 tempitem.wpn7 = 0;
8354 287 tempitem.wpn8 = 0;
8355 287 tempitem.wpn9 = 0;
8356 287 tempitem.wpn10 = 0;
8357 287 break;
8358 }
8359 case itype_key:
8360 {
8361 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8362 284 tempitem.misc1 = 0;
8363 284 tempitem.misc2 = 0;
8364 284 tempitem.misc3 = 0;
8365 284 tempitem.misc4 = 0;
8366 284 tempitem.misc5 = 0;
8367 284 tempitem.misc6 = 0;
8368 284 tempitem.misc7 = 0;
8369 284 tempitem.misc8 = 0;
8370 284 tempitem.misc9 = 0;
8371 284 tempitem.misc10 = 0;
8372 284 tempitem.wpn = 0;
8373 284 tempitem.wpn2 = 0;
8374 284 tempitem.wpn3 = 0;
8375 284 tempitem.wpn4 = 0;
8376 284 tempitem.wpn5 = 0;
8377 284 tempitem.wpn6 = 0;
8378 284 tempitem.wpn7 = 0;
8379 284 tempitem.wpn8 = 0;
8380 284 tempitem.wpn9 = 0;
8381 284 tempitem.wpn10 = 0;
8382 284 break;
8383 }
8384 case itype_magiccontainer:
8385 {
8386 289 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8387 289 tempitem.misc1 = 0;
8388 289 tempitem.misc2 = 0;
8389 289 tempitem.misc3 = 0;
8390 289 tempitem.misc4 = 0;
8391 289 tempitem.misc5 = 0;
8392 289 tempitem.misc6 = 0;
8393 289 tempitem.misc7 = 0;
8394 289 tempitem.misc8 = 0;
8395 289 tempitem.misc9 = 0;
8396 289 tempitem.misc10 = 0;
8397 289 tempitem.wpn = 0;
8398 289 tempitem.wpn2 = 0;
8399 289 tempitem.wpn3 = 0;
8400 289 tempitem.wpn4 = 0;
8401 289 tempitem.wpn5 = 0;
8402 289 tempitem.wpn6 = 0;
8403 289 tempitem.wpn7 = 0;
8404 289 tempitem.wpn8 = 0;
8405 289 tempitem.wpn9 = 0;
8406 289 tempitem.wpn10 = 0;
8407 289 break;
8408 }
8409 case itype_triforcepiece:
8410 {
8411 568 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8412 568 tempitem.misc3 = 0;
8413 568 tempitem.misc4 = 0;
8414 568 tempitem.misc5 = 0;
8415 568 tempitem.misc6 = 0;
8416 568 tempitem.misc7 = 0;
8417 568 tempitem.misc8 = 0;
8418 568 tempitem.misc9 = 0;
8419 568 tempitem.misc10 = 0;
8420 568 tempitem.wpn = 0;
8421 568 tempitem.wpn2 = 0;
8422 568 tempitem.wpn3 = 0;
8423 568 tempitem.wpn4 = 0;
8424 568 tempitem.wpn5 = 0;
8425 568 tempitem.wpn6 = 0;
8426 568 tempitem.wpn7 = 0;
8427 568 tempitem.wpn8 = 0;
8428 568 tempitem.wpn9 = 0;
8429 568 tempitem.wpn10 = 0;
8430 568 break;
8431 }
8432 case itype_map: case itype_compass: case itype_bosskey:
8433 {
8434 857 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8435 857 tempitem.misc1 = 0;
8436 857 tempitem.misc2 = 0;
8437 857 tempitem.misc3 = 0;
8438 857 tempitem.misc4 = 0;
8439 857 tempitem.misc5 = 0;
8440 857 tempitem.misc6 = 0;
8441 857 tempitem.misc7 = 0;
8442 857 tempitem.misc8 = 0;
8443 857 tempitem.misc9 = 0;
8444 857 tempitem.misc10 = 0;
8445 857 tempitem.wpn = 0;
8446 857 tempitem.wpn2 = 0;
8447 857 tempitem.wpn3 = 0;
8448 857 tempitem.wpn4 = 0;
8449 857 tempitem.wpn5 = 0;
8450 857 tempitem.wpn6 = 0;
8451 857 tempitem.wpn7 = 0;
8452 857 tempitem.wpn8 = 0;
8453 857 tempitem.wpn9 = 0;
8454 857 tempitem.wpn10 = 0;
8455 857 break;
8456 }
8457 case itype_quiver:
8458 {
8459 1136 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8460 1136 tempitem.misc3 = 0;
8461 1136 tempitem.misc4 = 0;
8462 1136 tempitem.misc5 = 0;
8463 1136 tempitem.misc6 = 0;
8464 1136 tempitem.misc7 = 0;
8465 1136 tempitem.misc8 = 0;
8466 1136 tempitem.misc9 = 0;
8467 1136 tempitem.misc10 = 0;
8468 1136 tempitem.wpn = 0;
8469 1136 tempitem.wpn2 = 0;
8470 1136 tempitem.wpn3 = 0;
8471 1136 tempitem.wpn4 = 0;
8472 1136 tempitem.wpn5 = 0;
8473 1136 tempitem.wpn6 = 0;
8474 1136 tempitem.wpn7 = 0;
8475 1136 tempitem.wpn8 = 0;
8476 1136 tempitem.wpn9 = 0;
8477 1136 tempitem.wpn10 = 0;
8478 1136 break;
8479 }
8480 case itype_lkey:
8481 {
8482 785 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8483 785 tempitem.misc1 = 0;
8484 785 tempitem.misc2 = 0;
8485 785 tempitem.misc3 = 0;
8486 785 tempitem.misc4 = 0;
8487 785 tempitem.misc5 = 0;
8488 785 tempitem.misc6 = 0;
8489 785 tempitem.misc7 = 0;
8490 785 tempitem.misc8 = 0;
8491 785 tempitem.misc9 = 0;
8492 785 tempitem.misc10 = 0;
8493 785 tempitem.wpn = 0;
8494 785 tempitem.wpn2 = 0;
8495 785 tempitem.wpn3 = 0;
8496 785 tempitem.wpn4 = 0;
8497 785 tempitem.wpn5 = 0;
8498 785 tempitem.wpn6 = 0;
8499 785 tempitem.wpn7 = 0;
8500 785 tempitem.wpn8 = 0;
8501 785 tempitem.wpn9 = 0;
8502 785 tempitem.wpn10 = 0;
8503 785 break;
8504 }
8505 case itype_cbyrna:
8506 {
8507 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8508 284 tempitem.misc4 = 0;
8509 284 tempitem.misc5 = 0;
8510 284 tempitem.misc6 = 0;
8511 284 tempitem.misc7 = 0;
8512 284 tempitem.misc8 = 0;
8513 284 tempitem.misc9 = 0;
8514 284 tempitem.misc10 = 0;
8515 284 tempitem.wpn6 = 0;
8516 284 tempitem.wpn7 = 0;
8517 284 tempitem.wpn8 = 0;
8518 284 tempitem.wpn9 = 0;
8519 284 tempitem.wpn10 = 0;
8520 284 break;
8521 }
8522 case itype_rupee: case itype_arrowammo:
8523 {
8524 3317 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8525 3317 tempitem.misc1 = 0;
8526 3317 tempitem.misc2 = 0;
8527 3317 tempitem.misc3 = 0;
8528 3317 tempitem.misc4 = 0;
8529 3317 tempitem.misc5 = 0;
8530 3317 tempitem.misc6 = 0;
8531 3317 tempitem.misc7 = 0;
8532 3317 tempitem.misc8 = 0;
8533 3317 tempitem.misc9 = 0;
8534 3317 tempitem.misc10 = 0;
8535 3317 tempitem.wpn = 0;
8536 3317 tempitem.wpn2 = 0;
8537 3317 tempitem.wpn3 = 0;
8538 3317 tempitem.wpn4 = 0;
8539 3317 tempitem.wpn5 = 0;
8540 3317 tempitem.wpn6 = 0;
8541 3317 tempitem.wpn7 = 0;
8542 3317 tempitem.wpn8 = 0;
8543 3317 tempitem.wpn9 = 0;
8544 3317 tempitem.wpn10 = 0;
8545 3317 break;
8546 }
8547 case itype_fairy:
8548 {
8549 555 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8550 555 tempitem.misc4 = 0;
8551 555 tempitem.misc5 = 0;
8552 555 tempitem.misc6 = 0;
8553 555 tempitem.misc7 = 0;
8554 555 tempitem.misc8 = 0;
8555 555 tempitem.misc9 = 0;
8556 555 tempitem.misc10 = 0;
8557 555 tempitem.wpn = 0;
8558 555 tempitem.wpn2 = 0;
8559 555 tempitem.wpn3 = 0;
8560 555 tempitem.wpn4 = 0;
8561 555 tempitem.wpn5 = 0;
8562 555 tempitem.wpn6 = 0;
8563 555 tempitem.wpn7 = 0;
8564 555 tempitem.wpn8 = 0;
8565 555 tempitem.wpn9 = 0;
8566 555 tempitem.wpn10 = 0;
8567 555 break;
8568 }
8569 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8570 {
8571 2923 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8572 2923 tempitem.misc1 = 0;
8573 2923 tempitem.misc2 = 0;
8574 2923 tempitem.misc3 = 0;
8575 2923 tempitem.misc4 = 0;
8576 2923 tempitem.misc5 = 0;
8577 2923 tempitem.misc6 = 0;
8578 2923 tempitem.misc7 = 0;
8579 2923 tempitem.misc8 = 0;
8580 2923 tempitem.misc9 = 0;
8581 2923 tempitem.misc10 = 0;
8582 2923 tempitem.wpn = 0;
8583 2923 tempitem.wpn2 = 0;
8584 2923 tempitem.wpn3 = 0;
8585 2923 tempitem.wpn4 = 0;
8586 2923 tempitem.wpn5 = 0;
8587 2923 tempitem.wpn6 = 0;
8588 2923 tempitem.wpn7 = 0;
8589 2923 tempitem.wpn8 = 0;
8590 2923 tempitem.wpn9 = 0;
8591 2923 tempitem.wpn10 = 0;
8592 2923 break;
8593 }
8594 case itype_bombbag:
8595 {
8596 1136 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8597 1136 tempitem.misc3 = 0;
8598 1136 tempitem.misc4 = 0;
8599 1136 tempitem.misc5 = 0;
8600 1136 tempitem.misc6 = 0;
8601 1136 tempitem.misc7 = 0;
8602 1136 tempitem.misc8 = 0;
8603 1136 tempitem.misc9 = 0;
8604 1136 tempitem.misc10 = 0;
8605 1136 tempitem.wpn = 0;
8606 1136 tempitem.wpn2 = 0;
8607 1136 tempitem.wpn3 = 0;
8608 1136 tempitem.wpn4 = 0;
8609 1136 tempitem.wpn5 = 0;
8610 1136 tempitem.wpn6 = 0;
8611 1136 tempitem.wpn7 = 0;
8612 1136 tempitem.wpn8 = 0;
8613 1136 tempitem.wpn9 = 0;
8614 1136 tempitem.wpn10 = 0;
8615 1136 break;
8616 }
8617 case itype_rocs:
8618 {
8619 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8620 284 tempitem.misc1 = 0;
8621 284 tempitem.misc2 = 0;
8622 284 tempitem.misc3 = 0;
8623 284 tempitem.misc4 = 0;
8624 284 tempitem.misc5 = 0;
8625 284 tempitem.misc6 = 0;
8626 284 tempitem.misc7 = 0;
8627 284 tempitem.misc8 = 0;
8628 284 tempitem.misc9 = 0;
8629 284 tempitem.misc10 = 0;
8630 284 tempitem.wpn = 0;
8631 284 tempitem.wpn2 = 0;
8632 284 tempitem.wpn3 = 0;
8633 284 tempitem.wpn4 = 0;
8634 284 tempitem.wpn5 = 0;
8635 284 tempitem.wpn6 = 0;
8636 284 tempitem.wpn7 = 0;
8637 284 tempitem.wpn8 = 0;
8638 284 tempitem.wpn9 = 0;
8639 284 tempitem.wpn10 = 0;
8640 284 break;
8641 }
8642 case itype_hoverboots:
8643 {
8644 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8645 284 tempitem.misc2 = 0;
8646 284 tempitem.misc3 = 0;
8647 284 tempitem.misc4 = 0;
8648 284 tempitem.misc5 = 0;
8649 284 tempitem.misc6 = 0;
8650 284 tempitem.misc7 = 0;
8651 284 tempitem.misc8 = 0;
8652 284 tempitem.misc9 = 0;
8653 284 tempitem.misc10 = 0;
8654 284 tempitem.wpn2 = 0;
8655 284 tempitem.wpn3 = 0;
8656 284 tempitem.wpn4 = 0;
8657 284 tempitem.wpn5 = 0;
8658 284 tempitem.wpn6 = 0;
8659 284 tempitem.wpn7 = 0;
8660 284 tempitem.wpn8 = 0;
8661 284 tempitem.wpn9 = 0;
8662 284 tempitem.wpn10 = 0;
8663 284 break;
8664 }
8665 case itype_spinscroll:
8666 {
8667 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8668 284 tempitem.misc2 = 0;
8669 284 tempitem.misc3 = 0;
8670 284 tempitem.misc4 = 0;
8671 284 tempitem.misc5 = 0;
8672 284 tempitem.misc6 = 0;
8673 284 tempitem.misc7 = 0;
8674 284 tempitem.misc8 = 0;
8675 284 tempitem.misc9 = 0;
8676 284 tempitem.misc10 = 0;
8677 284 tempitem.wpn = 0;
8678 284 tempitem.wpn2 = 0;
8679 284 tempitem.wpn3 = 0;
8680 284 tempitem.wpn4 = 0;
8681 284 tempitem.wpn5 = 0;
8682 284 tempitem.wpn6 = 0;
8683 284 tempitem.wpn7 = 0;
8684 284 tempitem.wpn8 = 0;
8685 284 tempitem.wpn9 = 0;
8686 284 tempitem.wpn10 = 0;
8687 284 break;
8688 }
8689 case itype_crossscroll:
8690 {
8691 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8692 284 tempitem.misc1 = 0;
8693 284 tempitem.misc2 = 0;
8694 284 tempitem.misc3 = 0;
8695 284 tempitem.misc4 = 0;
8696 284 tempitem.misc5 = 0;
8697 284 tempitem.misc6 = 0;
8698 284 tempitem.misc7 = 0;
8699 284 tempitem.misc8 = 0;
8700 284 tempitem.misc9 = 0;
8701 284 tempitem.misc10 = 0;
8702 284 tempitem.wpn = 0;
8703 284 tempitem.wpn2 = 0;
8704 284 tempitem.wpn3 = 0;
8705 284 tempitem.wpn4 = 0;
8706 284 tempitem.wpn5 = 0;
8707 284 tempitem.wpn6 = 0;
8708 284 tempitem.wpn7 = 0;
8709 284 tempitem.wpn8 = 0;
8710 284 tempitem.wpn9 = 0;
8711 284 tempitem.wpn10 = 0;
8712 284 break;
8713 }
8714 case itype_quakescroll:
8715 {
8716 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8717 284 tempitem.misc3 = 0;
8718 284 tempitem.misc4 = 0;
8719 284 tempitem.misc5 = 0;
8720 284 tempitem.misc6 = 0;
8721 284 tempitem.misc7 = 0;
8722 284 tempitem.misc8 = 0;
8723 284 tempitem.misc9 = 0;
8724 284 tempitem.misc10 = 0;
8725 284 tempitem.wpn = 0;
8726 284 tempitem.wpn2 = 0;
8727 284 tempitem.wpn3 = 0;
8728 284 tempitem.wpn4 = 0;
8729 284 tempitem.wpn5 = 0;
8730 284 tempitem.wpn6 = 0;
8731 284 tempitem.wpn7 = 0;
8732 284 tempitem.wpn8 = 0;
8733 284 tempitem.wpn9 = 0;
8734 284 tempitem.wpn10 = 0;
8735 284 break;
8736 }
8737 case itype_whispring:
8738 {
8739 571 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8740 571 tempitem.misc2 = 0;
8741 571 tempitem.misc3 = 0;
8742 571 tempitem.misc4 = 0;
8743 571 tempitem.misc5 = 0;
8744 571 tempitem.misc6 = 0;
8745 571 tempitem.misc7 = 0;
8746 571 tempitem.misc8 = 0;
8747 571 tempitem.misc9 = 0;
8748 571 tempitem.misc10 = 0;
8749 571 tempitem.wpn = 0;
8750 571 tempitem.wpn2 = 0;
8751 571 tempitem.wpn3 = 0;
8752 571 tempitem.wpn4 = 0;
8753 571 tempitem.wpn5 = 0;
8754 571 tempitem.wpn6 = 0;
8755 571 tempitem.wpn7 = 0;
8756 571 tempitem.wpn8 = 0;
8757 571 tempitem.wpn9 = 0;
8758 571 tempitem.wpn10 = 0;
8759 571 break;
8760 }
8761 case itype_chargering:
8762 {
8763 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8764 568 tempitem.misc3 = 0;
8765 568 tempitem.misc4 = 0;
8766 568 tempitem.misc5 = 0;
8767 568 tempitem.misc6 = 0;
8768 568 tempitem.misc7 = 0;
8769 568 tempitem.misc8 = 0;
8770 568 tempitem.misc9 = 0;
8771 568 tempitem.misc10 = 0;
8772 568 tempitem.wpn = 0;
8773 568 tempitem.wpn2 = 0;
8774 568 tempitem.wpn3 = 0;
8775 568 tempitem.wpn4 = 0;
8776 568 tempitem.wpn5 = 0;
8777 568 tempitem.wpn6 = 0;
8778 568 tempitem.wpn7 = 0;
8779 568 tempitem.wpn8 = 0;
8780 568 tempitem.wpn9 = 0;
8781 568 tempitem.wpn10 = 0;
8782 568 break;
8783 }
8784 case itype_perilscroll:
8785 {
8786 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8787 284 tempitem.misc2 = 0;
8788 284 tempitem.misc3 = 0;
8789 284 tempitem.misc4 = 0;
8790 284 tempitem.misc5 = 0;
8791 284 tempitem.misc6 = 0;
8792 284 tempitem.misc7 = 0;
8793 284 tempitem.misc8 = 0;
8794 284 tempitem.misc9 = 0;
8795 284 tempitem.misc10 = 0;
8796 284 tempitem.wpn = 0;
8797 284 tempitem.wpn2 = 0;
8798 284 tempitem.wpn3 = 0;
8799 284 tempitem.wpn4 = 0;
8800 284 tempitem.wpn5 = 0;
8801 284 tempitem.wpn6 = 0;
8802 284 tempitem.wpn7 = 0;
8803 284 tempitem.wpn8 = 0;
8804 284 tempitem.wpn9 = 0;
8805 284 tempitem.wpn10 = 0;
8806 284 break;
8807 }
8808 case itype_wealthmedal:
8809 {
8810 855 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8811 855 tempitem.misc2 = 0;
8812 855 tempitem.misc3 = 0;
8813 855 tempitem.misc4 = 0;
8814 855 tempitem.misc5 = 0;
8815 855 tempitem.misc6 = 0;
8816 855 tempitem.misc7 = 0;
8817 855 tempitem.misc8 = 0;
8818 855 tempitem.misc9 = 0;
8819 855 tempitem.misc10 = 0;
8820 855 tempitem.wpn = 0;
8821 855 tempitem.wpn2 = 0;
8822 855 tempitem.wpn3 = 0;
8823 855 tempitem.wpn4 = 0;
8824 855 tempitem.wpn5 = 0;
8825 855 tempitem.wpn6 = 0;
8826 855 tempitem.wpn7 = 0;
8827 855 tempitem.wpn8 = 0;
8828 855 tempitem.wpn9 = 0;
8829 855 tempitem.wpn10 = 0;
8830 855 break;
8831 }
8832 case itype_heartring:
8833 {
8834 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8835 858 tempitem.misc3 = 0;
8836 858 tempitem.misc4 = 0;
8837 858 tempitem.misc5 = 0;
8838 858 tempitem.misc6 = 0;
8839 858 tempitem.misc7 = 0;
8840 858 tempitem.misc8 = 0;
8841 858 tempitem.misc9 = 0;
8842 858 tempitem.misc10 = 0;
8843 858 tempitem.wpn = 0;
8844 858 tempitem.wpn2 = 0;
8845 858 tempitem.wpn3 = 0;
8846 858 tempitem.wpn4 = 0;
8847 858 tempitem.wpn5 = 0;
8848 858 tempitem.wpn6 = 0;
8849 858 tempitem.wpn7 = 0;
8850 858 tempitem.wpn8 = 0;
8851 858 tempitem.wpn9 = 0;
8852 858 tempitem.wpn10 = 0;
8853 858 break;
8854 }
8855 case itype_magicring:
8856 {
8857 1148 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8858 1148 tempitem.misc3 = 0;
8859 1148 tempitem.misc4 = 0;
8860 1148 tempitem.misc5 = 0;
8861 1148 tempitem.misc6 = 0;
8862 1148 tempitem.misc7 = 0;
8863 1148 tempitem.misc8 = 0;
8864 1148 tempitem.misc9 = 0;
8865 1148 tempitem.misc10 = 0;
8866 1148 tempitem.wpn = 0;
8867 1148 tempitem.wpn2 = 0;
8868 1148 tempitem.wpn3 = 0;
8869 1148 tempitem.wpn4 = 0;
8870 1148 tempitem.wpn5 = 0;
8871 1148 tempitem.wpn6 = 0;
8872 1148 tempitem.wpn7 = 0;
8873 1148 tempitem.wpn8 = 0;
8874 1148 tempitem.wpn9 = 0;
8875 1148 tempitem.wpn10 = 0;
8876 1148 break;
8877 }
8878 case itype_spinscroll2:
8879 {
8880 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8881 284 tempitem.misc2 = 0;
8882 284 tempitem.misc3 = 0;
8883 284 tempitem.misc4 = 0;
8884 284 tempitem.misc5 = 0;
8885 284 tempitem.misc6 = 0;
8886 284 tempitem.misc7 = 0;
8887 284 tempitem.misc8 = 0;
8888 284 tempitem.misc9 = 0;
8889 284 tempitem.misc10 = 0;
8890 284 tempitem.wpn = 0;
8891 284 tempitem.wpn2 = 0;
8892 284 tempitem.wpn3 = 0;
8893 284 tempitem.wpn4 = 0;
8894 284 tempitem.wpn5 = 0;
8895 284 tempitem.wpn6 = 0;
8896 284 tempitem.wpn7 = 0;
8897 284 tempitem.wpn8 = 0;
8898 284 tempitem.wpn9 = 0;
8899 284 tempitem.wpn10 = 0;
8900 284 break;
8901 }
8902 case itype_quakescroll2:
8903 {
8904 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8905 284 tempitem.misc3 = 0;
8906 284 tempitem.misc4 = 0;
8907 284 tempitem.misc5 = 0;
8908 284 tempitem.misc6 = 0;
8909 284 tempitem.misc7 = 0;
8910 284 tempitem.misc8 = 0;
8911 284 tempitem.misc9 = 0;
8912 284 tempitem.misc10 = 0;
8913 284 tempitem.wpn = 0;
8914 284 tempitem.wpn2 = 0;
8915 284 tempitem.wpn3 = 0;
8916 284 tempitem.wpn4 = 0;
8917 284 tempitem.wpn5 = 0;
8918 284 tempitem.wpn6 = 0;
8919 284 tempitem.wpn7 = 0;
8920 284 tempitem.wpn8 = 0;
8921 284 tempitem.wpn9 = 0;
8922 284 tempitem.wpn10 = 0;
8923 284 break;
8924 }
8925 case itype_agony:
8926 {
8927 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8928 284 tempitem.misc2 = 0;
8929 284 tempitem.misc3 = 0;
8930 284 tempitem.misc4 = 0;
8931 284 tempitem.misc5 = 0;
8932 284 tempitem.misc6 = 0;
8933 284 tempitem.misc7 = 0;
8934 284 tempitem.misc8 = 0;
8935 284 tempitem.misc9 = 0;
8936 284 tempitem.misc10 = 0;
8937 284 tempitem.wpn = 0;
8938 284 tempitem.wpn2 = 0;
8939 284 tempitem.wpn3 = 0;
8940 284 tempitem.wpn4 = 0;
8941 284 tempitem.wpn5 = 0;
8942 284 tempitem.wpn6 = 0;
8943 284 tempitem.wpn7 = 0;
8944 284 tempitem.wpn8 = 0;
8945 284 tempitem.wpn9 = 0;
8946 284 tempitem.wpn10 = 0;
8947 284 break;
8948 }
8949 case itype_stompboots:
8950 {
8951 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8952 284 tempitem.misc1 = 0;
8953 284 tempitem.misc2 = 0;
8954 284 tempitem.misc3 = 0;
8955 284 tempitem.misc4 = 0;
8956 284 tempitem.misc5 = 0;
8957 284 tempitem.misc6 = 0;
8958 284 tempitem.misc7 = 0;
8959 284 tempitem.misc8 = 0;
8960 284 tempitem.misc9 = 0;
8961 284 tempitem.misc10 = 0;
8962 284 tempitem.wpn = 0;
8963 284 tempitem.wpn2 = 0;
8964 284 tempitem.wpn3 = 0;
8965 284 tempitem.wpn4 = 0;
8966 284 tempitem.wpn5 = 0;
8967 284 tempitem.wpn6 = 0;
8968 284 tempitem.wpn7 = 0;
8969 284 tempitem.wpn8 = 0;
8970 284 tempitem.wpn9 = 0;
8971 284 tempitem.wpn10 = 0;
8972 284 break;
8973 }
8974 case itype_whimsicalring:
8975 {
8976 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8977 284 tempitem.misc2 = 0;
8978 284 tempitem.misc3 = 0;
8979 284 tempitem.misc4 = 0;
8980 284 tempitem.misc5 = 0;
8981 284 tempitem.misc6 = 0;
8982 284 tempitem.misc7 = 0;
8983 284 tempitem.misc8 = 0;
8984 284 tempitem.misc9 = 0;
8985 284 tempitem.misc10 = 0;
8986 284 tempitem.wpn = 0;
8987 284 tempitem.wpn2 = 0;
8988 284 tempitem.wpn3 = 0;
8989 284 tempitem.wpn4 = 0;
8990 284 tempitem.wpn5 = 0;
8991 284 tempitem.wpn6 = 0;
8992 284 tempitem.wpn7 = 0;
8993 284 tempitem.wpn8 = 0;
8994 284 tempitem.wpn9 = 0;
8995 284 tempitem.wpn10 = 0;
8996 284 break;
8997 }
8998 case itype_perilring:
8999 {
9000 311 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9001 311 tempitem.misc2 = 0;
9002 311 tempitem.misc3 = 0;
9003 311 tempitem.misc4 = 0;
9004 311 tempitem.misc5 = 0;
9005 311 tempitem.misc6 = 0;
9006 311 tempitem.misc7 = 0;
9007 311 tempitem.misc8 = 0;
9008 311 tempitem.misc9 = 0;
9009 311 tempitem.misc10 = 0;
9010 311 tempitem.wpn = 0;
9011 311 tempitem.wpn2 = 0;
9012 311 tempitem.wpn3 = 0;
9013 311 tempitem.wpn4 = 0;
9014 311 tempitem.wpn5 = 0;
9015 311 tempitem.wpn6 = 0;
9016 311 tempitem.wpn7 = 0;
9017 311 tempitem.wpn8 = 0;
9018 311 tempitem.wpn9 = 0;
9019 311 tempitem.wpn10 = 0;
9020 311 break;
9021 }
9022 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9023 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9024 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9025 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9026 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9027 {
9028 10996 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9029 10996 tempitem.misc1 = 0;
9030 10996 tempitem.misc2 = 0;
9031 10996 tempitem.misc3 = 0;
9032 10996 tempitem.misc4 = 0;
9033 10996 tempitem.misc5 = 0;
9034 10996 tempitem.misc6 = 0;
9035 10996 tempitem.misc7 = 0;
9036 10996 tempitem.misc8 = 0;
9037 10996 tempitem.misc9 = 0;
9038 10996 tempitem.misc10 = 0;
9039 10996 tempitem.wpn = 0;
9040 10996 tempitem.wpn2 = 0;
9041 10996 tempitem.wpn3 = 0;
9042 10996 tempitem.wpn4 = 0;
9043 10996 tempitem.wpn5 = 0;
9044 10996 tempitem.wpn6 = 0;
9045 10996 tempitem.wpn7 = 0;
9046 10996 tempitem.wpn8 = 0;
9047 10996 tempitem.wpn9 = 0;
9048 10996 tempitem.wpn10 = 0;
9049 10996 break;
9050 }
9051 }
9052 73472 }
9053 //Port quest rules to items
9054
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version <= 31)
9055 {
9056
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 73172 times.
73472 if(tempitem.family == itype_bomb)
9057 {
9058
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 144 times.
300 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9059 144 else tempitem.flags &= ~ item_flag2;
9060 300 }
9061
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 72886 times.
73172 else if(tempitem.family == itype_sbomb)
9062 {
9063
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 128 times.
286 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9064 128 else tempitem.flags &= ~ item_flag2;
9065 286 }
9066
9067
2/2
✓ Branch 0 taken 859 times.
✓ Branch 1 taken 72027 times.
72886 else if(tempitem.family == itype_brang)
9068 {
9069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 859 times.
859 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9070 859 else tempitem.flags &= ~ item_flag4;
9071 859 }
9072
2/2
✓ Branch 0 taken 71725 times.
✓ Branch 1 taken 302 times.
72027 else if(tempitem.family == itype_wand)
9073 {
9074
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9075 278 else tempitem.flags &= ~ item_flag3;
9076 302 }
9077 73472 }
9078
9079 //Port quest rules to items
9080
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version <= 37)
9081 {
9082
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 73185 times.
73472 if(tempitem.family == itype_flippers)
9083 {
9084
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 208 times.
287 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9085 208 else tempitem.flags &= ~ item_flag1;
9086 287 }
9087
2/2
✓ Branch 0 taken 55497 times.
✓ Branch 1 taken 17688 times.
73185 else if(tempitem.family == itype_sword)
9088 {
9089
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 17226 times.
17688 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9090 17226 else tempitem.flags &= ~ item_flag5;
9091 17688 }
9092
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 55195 times.
55497 else if(tempitem.family == itype_wand)
9093 {
9094
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 292 times.
302 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9095 292 else tempitem.flags &= ~ item_flag5;
9096 302 }
9097
4/4
✓ Branch 0 taken 54895 times.
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 610 times.
✓ Branch 3 taken 54285 times.
55195 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9098 {
9099 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9100
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 529 times.
910 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9101 529 else tempitem.flags &= ~ item_flag3;
9102 910 }
9103 73472 }
9104
9105
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 38)
9106 {
9107
4/4
✓ Branch 0 taken 72613 times.
✓ Branch 1 taken 859 times.
✓ Branch 2 taken 570 times.
✓ Branch 3 taken 72043 times.
73472 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9108 {
9109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1429 times.
1429 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9110 1429 else tempitem.flags &= ~item_flag4;
9111
9112
2/2
✓ Branch 0 taken 703 times.
✓ Branch 1 taken 726 times.
1429 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9113 726 else tempitem.flags &= ~(item_flag5|item_flag6);
9114 1429 }
9115
2/2
✓ Branch 0 taken 71199 times.
✓ Branch 1 taken 844 times.
72043 else if(tempitem.family == itype_arrow)
9116 {
9117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9118 844 else tempitem.flags &= ~item_flag4;
9119
9120
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 432 times.
844 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9121 432 else tempitem.flags |= item_flag2;
9122 844 }
9123 73472 }
9124
9125
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 39)
9126 {
9127
6/6
✓ Branch 0 taken 73188 times.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 72888 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 610 times.
✓ Branch 5 taken 72278 times.
73472 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9128 {
9129
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1178 times.
1194 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9130 1178 else tempitem.flags &= ~item_flag5;
9131 1194 }
9132
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 71655 times.
72278 else if(tempitem.family == itype_potion)
9133 {
9134
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 461 times.
623 if(get_qr(qr_NONBUBBLEMEDICINE))
9135 {
9136 162 tempitem.flags &= ~(item_flag3|item_flag4);
9137 162 }
9138 else
9139 {
9140 461 tempitem.flags |= item_flag3;
9141
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 331 times.
461 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9142 331 else tempitem.flags &= ~item_flag4;
9143 }
9144 623 }
9145
2/2
✓ Branch 0 taken 71087 times.
✓ Branch 1 taken 568 times.
71655 else if(tempitem.family == itype_triforcepiece)
9146 {
9147
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 484 times.
568 if(get_qr(qr_NONBUBBLETRIFORCE))
9148 {
9149 84 tempitem.flags |= item_flag3;
9150
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9151 28 else tempitem.flags &= ~item_flag4;
9152 84 }
9153 else
9154 {
9155 484 tempitem.flags &= ~(item_flag3|item_flag4);
9156 }
9157 568 }
9158 73472 }
9159
9160
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 40)
9161 {
9162
4/4
✓ Branch 0 taken 72540 times.
✓ Branch 1 taken 932 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 72229 times.
73472 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9163 {
9164
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 930 times.
1243 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9165 930 else tempitem.flags &= ~item_flag1;
9166 1243 }
9167
8/8
✓ Branch 0 taken 71619 times.
✓ Branch 1 taken 610 times.
✓ Branch 2 taken 53931 times.
✓ Branch 3 taken 17688 times.
✓ Branch 4 taken 53629 times.
✓ Branch 5 taken 302 times.
✓ Branch 6 taken 284 times.
✓ Branch 7 taken 53345 times.
72229 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9168 {
9169
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18776 times.
18884 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9170 18776 else tempitem.flags &= ~item_flag8;
9171 18884 }
9172
6/6
✓ Branch 0 taken 55784 times.
✓ Branch 1 taken 17688 times.
✓ Branch 2 taken 55482 times.
✓ Branch 3 taken 302 times.
✓ Branch 4 taken 287 times.
✓ Branch 5 taken 55195 times.
73472 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9173 {
9174
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 18173 times.
18277 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9175 18173 else tempitem.flags &= ~item_flag7;
9176 18277 }
9177
2/2
✓ Branch 0 taken 54911 times.
✓ Branch 1 taken 284 times.
55195 else if(tempitem.family == itype_cbyrna)
9178 {
9179 284 tempitem.flags |= item_flag7;
9180 284 }
9181 73472 }
9182
9183
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 41 )
9184 {
9185
2/2
✓ Branch 0 taken 55784 times.
✓ Branch 1 taken 17688 times.
73472 if(tempitem.family == itype_sword)
9186 {
9187
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 17404 times.
17688 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9188 17404 else tempitem.flags &= ~item_flag9;
9189
9190
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17260 times.
17688 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9191 17260 else tempitem.flags &= ~item_flag10;
9192 17688 }
9193 73472 }
9194
9195
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 42 )
9196 {
9197
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 73170 times.
73472 if(tempitem.family == itype_wand)
9198 {
9199
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9200 278 else tempitem.flags &= ~item_flag3;
9201
9202 302 tempitem.flags &= ~item_flag6;
9203 302 }
9204
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 72883 times.
73170 else if(tempitem.family == itype_hammer)
9205 {
9206 287 tempitem.flags &= ~item_flag3;
9207 287 }
9208
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 72599 times.
72883 else if(tempitem.family == itype_cbyrna)
9209 {
9210 284 tempitem.flags |= item_flag3;
9211
9212 284 tempitem.flags &= ~item_flag6;
9213 284 }
9214
2/2
✓ Branch 0 taken 54911 times.
✓ Branch 1 taken 17688 times.
72599 else if(tempitem.family == itype_sword)
9215 {
9216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17688 times.
17688 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9217 17688 else tempitem.flags &= ~item_flag6;
9218 17688 }
9219 73472 }
9220
9221
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 43 )
9222 {
9223
2/2
✓ Branch 0 taken 73140 times.
✓ Branch 1 taken 332 times.
73472 if(tempitem.family == itype_whistle)
9224 {
9225
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 320 times.
332 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9226 320 else tempitem.flags &= ~item_flag3;
9227 332 }
9228 73472 }
9229
9230
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 45 )
9231 {
9232
2/2
✓ Branch 0 taken 73185 times.
✓ Branch 1 taken 287 times.
73472 if(tempitem.family == itype_flippers)
9233 {
9234 287 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9235 287 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9236 287 }
9237 73472 }
9238
9239
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 46 )
9240 {
9241
2/2
✓ Branch 0 taken 73188 times.
✓ Branch 1 taken 284 times.
73472 if(tempitem.family == itype_raft)
9242 {
9243 284 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9244 284 }
9245 73472 }
9246
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if ( s_version < 34 ) //! set the default counter for older quests.
9247 {
9248
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 73357 times.
73472 if ( (tempitem.flags & item_rupee_magic) )
9249 {
9250 115 tempitem.cost_counter[0] = 1;
9251 115 }
9252 else
9253 {
9254
2/2
✓ Branch 0 taken 44032 times.
✓ Branch 1 taken 29325 times.
73357 if(get_qr(qr_ENABLEMAGIC))
9255 44032 tempitem.cost_counter[0] = 4;
9256 else
9257 {
9258 29325 tempitem.cost_amount[0] = 0;
9259 29325 tempitem.cost_counter[0] = -1;
9260 }
9261 }
9262 73472 }
9263
9264
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if ( s_version < 35 ) //new Lens of Truth flags
9265 {
9266
2/2
✓ Branch 0 taken 73212 times.
✓ Branch 1 taken 260 times.
73472 if ( tempitem.family == itype_lens )
9267 {
9268
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 12 times.
260 if ( get_qr(qr_RAFTLENS) )
9269 {
9270 12 tempitem.flags |= item_flag4;
9271 12 }
9272
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 167 times.
260 if ( get_qr(qr_LENSHINTS) )
9273 {
9274 167 tempitem.flags |= item_flag1;
9275 167 }
9276
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 16 times.
260 if ( get_qr(qr_LENSSEESENEMIES) )
9277 {
9278 16 tempitem.flags |= item_flag5;
9279 16 }
9280 260 }
9281 73472 }
9282
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9283 {
9284
2/2
✓ Branch 0 taken 587776 times.
✓ Branch 1 taken 73472 times.
661248 for ( int32_t q = 0; q < 8; q++ )
9285 {
9286 587776 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9287 587776 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9288 587776 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9289 587776 tempitem.sprite_initiald[q] = 0;
9290 587776 }
9291 73472 tempitem.sprite_script = 0;
9292 73472 }
9293
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9294 {
9295 73472 tempitem.pickupflag = 0;
9296 73472 }
9297
9298
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 51 )
9299 {
9300
2/2
✓ Branch 0 taken 72862 times.
✓ Branch 1 taken 610 times.
73472 if( tempitem.family == itype_candle )
9301 {
9302 610 tempitem.misc4 = 50; //Step speed
9303 610 }
9304 73472 }
9305
9306
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if( s_version < 52 )
9307 {
9308
2/2
✓ Branch 0 taken 72599 times.
✓ Branch 1 taken 873 times.
73472 if( tempitem.family == itype_shield )
9309 873 tempitem.flags |= item_flag1; //'Block Front' flag
9310 73472 }
9311
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 73472 times.
120064 if(s_version < 53)
9312 {
9313
4/4
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 72042 times.
✓ Branch 2 taken 844 times.
✓ Branch 3 taken 286 times.
73472 switch(tempitem.family)
9314 {
9315 case itype_arrow:
9316 844 tempitem.cost_counter[1] = crARROWS;
9317 844 tempitem.cost_amount[1] = 1;
9318 844 break;
9319 case itype_bomb:
9320 300 tempitem.cost_counter[1] = crBOMBS;
9321 300 tempitem.cost_amount[1] = 1;
9322 300 break;
9323 case itype_sbomb:
9324 286 tempitem.cost_counter[1] = crSBOMBS;
9325 286 tempitem.cost_amount[1] = 1;
9326 286 break;
9327 default:
9328 72042 tempitem.cost_counter[1] = crNONE;
9329 72042 tempitem.cost_amount[1] = 0;
9330 72042 }
9331 73472 tempitem.magiccosttimer[1] = 0;
9332 73472 }
9333
2/2
✓ Branch 0 taken 43776 times.
✓ Branch 1 taken 76288 times.
120064 if( s_version < 54 )
9334 {
9335
2/2
✓ Branch 0 taken 75988 times.
✓ Branch 1 taken 300 times.
76288 if( tempitem.family == itype_flippers )
9336 300 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9337 76288 }
9338
2/2
✓ Branch 0 taken 43776 times.
✓ Branch 1 taken 76288 times.
120064 if(s_version < 55)
9339 {
9340
3/3
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 75108 times.
76288 switch(tempitem.family)
9341 {
9342 case itype_spinscroll:
9343 case itype_quakescroll:
9344 590 tempitem.usesound2 = WAV_ZN1CHARGE;
9345 590 break;
9346 case itype_spinscroll2:
9347 case itype_quakescroll2:
9348 590 tempitem.usesound2 = WAV_ZN1CHARGE2;
9349 590 break;
9350 }
9351 76288 }
9352
2/2
✓ Branch 0 taken 43776 times.
✓ Branch 1 taken 76288 times.
120064 if(s_version < 56)
9353 {
9354
4/4
✓ Branch 0 taken 75046 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 311 times.
76288 switch(tempitem.family)
9355 {
9356 case itype_divinefire:
9357
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 11 times.
295 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9358
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 213 times.
295 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9359 295 tempitem.flags |= item_flag11; //Divine Fire
9360 295 break;
9361 case itype_candle:
9362
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 319 times.
636 SETFLAG(tempitem.flags, item_flag9, tempitem.fam_type > 1); //Strong Fire
9363 636 tempitem.flags &= ~item_flag10; //Magic Fire
9364 636 tempitem.flags &= ~item_flag11; //Divine Fire
9365 636 break;
9366 case itype_book:
9367 311 tempitem.flags |= item_flag9; //Strong Fire
9368 311 tempitem.flags |= item_flag10; //Magic Fire
9369 311 tempitem.flags &= ~item_flag11; //Divine Fire
9370 311 break;
9371 }
9372 76288 }
9373
2/2
✓ Branch 0 taken 30464 times.
✓ Branch 1 taken 89600 times.
120064 if (s_version < 61)
9374 {
9375
2/2
✓ Branch 0 taken 70649 times.
✓ Branch 1 taken 18951 times.
89600 switch (tempitem.family)
9376 {
9377 case itype_sword:
9378 18951 tempitem.usesound2 = WAV_BEAM;
9379 18951 break;
9380 }
9381 89600 }
9382
9383
9384
2/2
✓ Branch 0 taken 10988 times.
✓ Branch 1 taken 109076 times.
120064 if(tempitem.fam_type==0) // Always do this
9385 10988 tempitem.fam_type=1;
9386
9387 120064 itemsbuf[i] = tempitem;
9388 120064 }
9389
9390 469 return 0;
9391 470 }
9392
9393 static bool did_init_def_items = false;
9394 239994 void init_def_items()
9395 {
9396
2/2
✓ Branch 0 taken 239631 times.
✓ Branch 1 taken 363 times.
239994 if(did_init_def_items) return;
9397 363 did_init_def_items = true;
9398 363 default_items[3].cost_counter[1] = crBOMBS;
9399 363 default_items[13].cost_counter[1] = crARROWS;
9400 363 default_items[14].cost_counter[1] = crARROWS;
9401 363 default_items[48].cost_counter[1] = crSBOMBS;
9402 363 default_items[57].cost_counter[1] = crARROWS;
9403 239994 }
9404 239994 void reset_itembuf(itemdata *item, int32_t id)
9405 {
9406 239994 init_def_items();
9407
2/2
✓ Branch 0 taken 100683 times.
✓ Branch 1 taken 139311 times.
239994 if(id<iLast)
9408 {
9409 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9410 139311 word tile = item->tile;
9411 139311 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9412 139311 int32_t ltm = item->ltm;
9413
9414 139311 *item = default_items[id];
9415 139311 item->tile = tile;
9416 139311 item->misc_flags = miscs;
9417 139311 item->csets = cset;
9418 139311 item->frames = frames;
9419 139311 item->speed = speed;
9420 139311 item->delay = delay;
9421 139311 item->ltm = ltm;
9422 139311 }
9423 239994 }
9424
9425 100096 void reset_itemname(int32_t id)
9426 {
9427 100096 sprintf(item_string[id],"zz%03d",id);
9428
9429
2/2
✓ Branch 0 taken 44183 times.
✓ Branch 1 taken 55913 times.
100096 if(id < iLast)
9430 55913 strcpy(item_string[id],old_item_string[id]);
9431 100096 }
9432
9433 470 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9434 {
9435
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9436
9437 470 word weapons_to_read=MAXWPNS;
9438 int32_t dummy;
9439 byte padding;
9440 wpndata tempweapon;
9441 470 word s_version=0;
9442
9443
9444
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6 times.
470 if(Header->zelda_version < 0x186)
9445 {
9446 6 weapons_to_read=64;
9447 6 }
9448
9449
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6 times.
470 if(Header->zelda_version < 0x185)
9450 {
9451 6 weapons_to_read=32;
9452 6 }
9453
9454
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 446 times.
470 if(Header->zelda_version > 0x192)
9455 {
9456 446 weapons_to_read=0;
9457
9458 //section version info
9459
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&s_version,f))
9460 {
9461 return qe_invalid;
9462 }
9463
9464 446 FFCore.quest_format[vWeaponSprites] = s_version;
9465
9466
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!read_deprecated_section_cversion(f))
9467 {
9468 return qe_invalid;
9469 }
9470
9471 //section size
9472
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
9473 {
9474 return qe_invalid;
9475 }
9476
9477 //finally... section data
9478
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&weapons_to_read,f))
9479 {
9480 return qe_invalid;
9481 }
9482
9483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if (weapons_to_read > MAXWPNS)
9484 {
9485 return qe_invalid;
9486 }
9487 446 }
9488
9489
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 83 times.
470 if(s_version>2)
9490 {
9491
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i=0; i<weapons_to_read; i++)
9492 {
9493 char tempname[64];
9494
9495
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if(!pfread(tempname, 64, f))
9496 {
9497 return qe_invalid;
9498 }
9499
9500 99072 weapon_string[i][0] = '\0';
9501 99072 strncat(weapon_string[i], tempname, 64 - 1);
9502 99072 }
9503
9504
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version<4)
9505 {
9506 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9507 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9508 }
9509
9510
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version<5)
9511 {
9512 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9513 }
9514
9515 /*
9516 if (s_version<6)
9517 {
9518 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9519 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9520 }
9521 */
9522 387 }
9523
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9524 {
9525
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9526 20992 reset_weaponname(i);
9527 82 }
9528
9529
2/2
✓ Branch 0 taken 107884 times.
✓ Branch 1 taken 470 times.
108354 for(int32_t i=0; i<weapons_to_read; i++)
9530 {
9531 107884 word oldtile = 0;
9532
2/2
✓ Branch 0 taken 45312 times.
✓ Branch 1 taken 62572 times.
107884 if (s_version < 8)
9533 {
9534
1/2
✓ Branch 0 taken 62572 times.
✗ Branch 1 not taken.
62572 if (!p_igetw(&oldtile, f))
9535 return qe_invalid;
9536 62572 }
9537
9538
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.misc,f))
9539 {
9540 return qe_invalid;
9541 }
9542
9543
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.csets,f))
9544 {
9545 return qe_invalid;
9546 }
9547
9548
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.frames,f))
9549 {
9550 return qe_invalid;
9551 }
9552
9553
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.speed,f))
9554 {
9555 return qe_invalid;
9556 }
9557
9558
1/2
✓ Branch 0 taken 107884 times.
✗ Branch 1 not taken.
107884 if(!p_getc(&tempweapon.type,f))
9559 {
9560 return qe_invalid;
9561 }
9562
9563
2/2
✓ Branch 0 taken 61292 times.
✓ Branch 1 taken 46592 times.
107884 if ( s_version >= 7 )
9564 {
9565
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetw(&tempweapon.script,f))
9566 {
9567 return qe_invalid;
9568 }
9569
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if(!p_igetl(&tempweapon.tile,f))
9570 {
9571 return qe_invalid;
9572 }
9573 46592 }
9574
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 61292 times.
107884 if ( s_version < 7 )
9575 {
9576 61292 tempweapon.tile = oldtile;
9577 61292 }
9578
9579
2/2
✓ Branch 0 taken 103084 times.
✓ Branch 1 taken 4800 times.
107884 if(Header->zelda_version < 0x193)
9580 {
9581
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9582 {
9583 return qe_invalid;
9584 }
9585 4800 }
9586
9587
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 8812 times.
107884 if(s_version < 6)
9588 {
9589
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9590 {
9591 18 tempweapon.misc |= WF_BEHIND;
9592 18 }
9593 else
9594 8794 tempweapon.misc &= ~WF_BEHIND;
9595 8812 }
9596
9597
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 107628 times.
107884 if (!should_skip)
9598 107628 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9599 107884 }
9600
9601
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (should_skip)
9602 1 return 0;
9603
9604
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<2)
9605 {
9606 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9607 82 }
9608
9609
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(s_version<5)
9610 {
9611 82 wpnsbuf[iwQuarterHearts].tile=1;
9612 82 wpnsbuf[iwQuarterHearts].csets=1;
9613 82 }
9614
9615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(Header->zelda_version < 0x176)
9616 {
9617 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9618 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9619 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9620 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9621 }
9622
9623
3/4
✓ Branch 0 taken 451 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
474 if((Header->zelda_version < 0x192)||
9624
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 446 times.
451 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9625 {
9626 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9627 18 }
9628
9629
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if((Header->zelda_version < 0x210))
9630 {
9631 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9632 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9633 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9634 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9635 23 }
9636
9637 469 return 0;
9638 470 }
9639
9640 221721 static void guy_update_firesfx(guydata& tempguy)
9641 {
9642 221721 tempguy.firesfx = 0;
9643
2/2
✓ Branch 0 taken 6367 times.
✓ Branch 1 taken 215354 times.
221721 if (tempguy.family == eeWIZZ)
9644 {
9645
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
✓ Branch 2 taken 3891 times.
✓ Branch 3 taken 819 times.
✓ Branch 4 taken 692 times.
6367 switch (tempguy.attributes[1])
9646 {
9647 case 0: // normal weapon
9648 3891 tempguy.firesfx = WAV_WAND;
9649 3891 break;
9650 case 1: // 8 shots
9651
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 737 times.
819 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9652 else
9653 {
9654
3/8
✓ Branch 0 taken 634 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
737 switch (tempguy.weapon)
9655 {
9656 case ewFireTrail:
9657 case ewFlame:
9658 case ewFlame2Trail:
9659 case ewFlame2:
9660 634 tempguy.firesfx = WAV_FIRE;
9661 634 break;
9662 case ewWind:
9663 case ewMagic:
9664 87 tempguy.firesfx = WAV_WAND;
9665 87 break;
9666 case ewIce:
9667 tempguy.firesfx = WAV_ZN1ICE;
9668 break;
9669 case ewRock:
9670 tempguy.firesfx = WAV_ZN1ROCK;
9671 break;
9672 case ewFireball2:
9673 case ewFireball:
9674 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9675 16 break;
9676 case ewBrang:
9677 tempguy.firesfx = WAV_BRANG;
9678 break;
9679 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9680 tempguy.firesfx = WAV_BOMB;
9681 break;
9682 default:
9683 tempguy.firesfx = 0;
9684 break;
9685 }
9686 737 break;
9687 }
9688 case 2: // Summon
9689 1047 tempguy.firesfx = WAV_FIRE;
9690 1047 break;
9691 case 3: // Summon Layer
9692 692 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9693 692 break;
9694 }
9695 6367 }
9696 else
9697 {
9698
6/6
✓ Branch 0 taken 163151 times.
✓ Branch 1 taken 52203 times.
✓ Branch 2 taken 41491 times.
✓ Branch 3 taken 204642 times.
✓ Branch 4 taken 46849 times.
✓ Branch 5 taken 46845 times.
215354 if ((tempguy.family == eeWALK || tempguy.family == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9699 {
9700 93694 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9701 93694 }
9702 else
9703 {
9704
7/8
✓ Branch 0 taken 9515 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 1790 times.
✓ Branch 3 taken 12698 times.
✓ Branch 4 taken 172141 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3921 times.
✓ Branch 7 taken 2244 times.
204642 switch (tempguy.weapon)
9705 {
9706 case ewFireTrail:
9707 case ewFlame:
9708 case ewFlame2Trail:
9709 case ewFlame2:
9710 9515 tempguy.firesfx = WAV_FIRE;
9711 9515 break;
9712 case ewWind:
9713 case ewMagic:
9714 1790 tempguy.firesfx = WAV_WAND;
9715 1790 break;
9716 case ewIce:
9717 tempguy.firesfx = WAV_ZN1ICE;
9718 break;
9719 case ewRock:
9720 3921 tempguy.firesfx = WAV_ZN1ROCK;
9721 3921 break;
9722 case ewFireball2:
9723 case ewFireball:
9724 12698 tempguy.firesfx = WAV_ZN1FIREBALL;
9725 12698 break;
9726 case ewBrang:
9727 2244 tempguy.firesfx = WAV_BRANG;
9728 2244 break;
9729 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9730 2333 tempguy.firesfx = WAV_BOMB;
9731 2333 break;
9732 default:
9733 172141 tempguy.firesfx = 0;
9734 172141 break;
9735 }
9736 }
9737 }
9738 211013 }
9739
9740 211013 static void guy_update_weaponflags(guydata& tempguy)
9741 {
9742 211013 tempguy.wunblockable = 0;
9743 211013 tempguy.wmoveflags = move_none;
9744
4/4
✓ Branch 0 taken 204557 times.
✓ Branch 1 taken 6456 times.
✓ Branch 2 taken 2970 times.
✓ Branch 3 taken 201587 times.
211013 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9745 9426 tempguy.wmoveflags |= (move_obeys_grav | move_can_pitfall);
9746 211013 tempguy.weapoverrideFLAGS = 0;
9747 211013 tempguy.weap_hxofs = 0;
9748 211013 tempguy.weap_hyofs = 0;
9749 211013 tempguy.weap_hxsz = 0;
9750 211013 tempguy.weap_hysz = 0;
9751 211013 tempguy.weap_hzsz = 0;
9752 211013 tempguy.weap_xofs = 0;
9753 211013 tempguy.weap_yofs = 0;
9754 211013 tempguy.weap_tilew = 0;
9755 211013 tempguy.weap_tileh = 0;
9756
5/5
✓ Branch 0 taken 2483 times.
✓ Branch 1 taken 170179 times.
✓ Branch 2 taken 18333 times.
✓ Branch 3 taken 12714 times.
✓ Branch 4 taken 7304 times.
211013 switch (tempguy.weapon)
9757 {
9758 case ewFireball: case ewFireball2:
9759 12714 tempguy.wstep = 175;
9760 12714 break;
9761 case ewSword: case ewLitBomb: case ewLitSBomb:
9762 case ewRock: case ewMagic: case ewWind:
9763 18333 tempguy.wstep = 300;
9764 18333 break;
9765 case ewArrow:
9766 2483 tempguy.wstep = 200;
9767 2483 break;
9768 case ewFlame: case ewFlame2:
9769 7304 tempguy.wstep = 100;
9770 7304 break;
9771 default:
9772 170179 tempguy.wstep = 0;
9773 170179 break;
9774 }
9775
2/2
✓ Branch 0 taken 1055065 times.
✓ Branch 1 taken 211013 times.
1266078 for (int q = 0; q < WPNSPR_MAX; ++q)
9776 {
9777 1055065 tempguy.burnsprs[q] = 0;
9778 1055065 tempguy.light_rads[q] = 0;
9779 1055065 }
9780 211013 }
9781
9782 211013 static void guy_update_weaponspecialsfx(guydata& tempguy)
9783 {
9784
3/3
✓ Branch 0 taken 2244 times.
✓ Branch 1 taken 206381 times.
✓ Branch 2 taken 2388 times.
211013 switch (tempguy.weapon)
9785 {
9786 case ewBrang:
9787 2244 tempguy.specialsfx = WAV_BRANG;
9788 2244 break;
9789 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9790 2388 tempguy.specialsfx = WAV_BOMB;
9791 2388 break;
9792 default:
9793 206381 tempguy.specialsfx = 0;
9794 206381 break;
9795 }
9796 211013 }
9797
9798 469 void init_guys(int32_t guyversion)
9799 {
9800
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<MAXGUYS; i++)
9801 {
9802 240128 guysbuf[i] = default_guys[0];
9803 240128 }
9804
9805
2/2
✓ Branch 0 taken 83013 times.
✓ Branch 1 taken 469 times.
83482 for(int32_t i=0; i<OLDMAXGUYS; i++)
9806 {
9807 83013 guysbuf[i] = default_guys[i];
9808
2/2
✓ Branch 0 taken 82075 times.
✓ Branch 1 taken 938 times.
83013 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9809 83013 guysbuf[i].spr_death = iwDeath;
9810 83013 guysbuf[i].spr_spawn = iwSpawn;
9811 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9812
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 68499 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
83013 if(guyversion<=3 && i==ePATRABS)
9813 {
9814 82 guysbuf[i].bosspal=spDIG;
9815 82 guysbuf[i].cset=14;
9816 82 guysbuf[i].attributes[8] = 14;
9817 82 }
9818
9819
2/2
✓ Branch 0 taken 68499 times.
✓ Branch 1 taken 14514 times.
83013 if(guyversion<=3)
9820 {
9821 // Rope/Ghini Flash rules
9822
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9823 {
9824
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9825 {
9826 59 guysbuf[i].flags &= ~guy_flashing;
9827 59 }
9828 10443 }
9829
9830
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9831 {
9832
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9833 {
9834 72 guysbuf[i].flags &= ~guy_flashing;
9835 72 }
9836 2124 }
9837
9838
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9839 {
9840
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9841 {
9842 4 guysbuf[i].flags |= guy_blinking;
9843 4 }
9844
9845
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9846 {
9847 38 guysbuf[i].flags |= guy_transparent;
9848 38 }
9849 82 }
9850
9851
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9852 {
9853 164 guysbuf[i].flags |= guy_ignore_kill_all;
9854 164 }
9855 14514 }
9856
9857 // Darknut fix
9858
10/10
✓ Branch 0 taken 82544 times.
✓ Branch 1 taken 469 times.
✓ Branch 2 taken 82075 times.
✓ Branch 3 taken 469 times.
✓ Branch 4 taken 81606 times.
✓ Branch 5 taken 469 times.
✓ Branch 6 taken 81137 times.
✓ Branch 7 taken 469 times.
✓ Branch 8 taken 469 times.
✓ Branch 9 taken 80668 times.
83013 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9859 {
9860
2/2
✓ Branch 0 taken 1940 times.
✓ Branch 1 taken 405 times.
2345 if(get_qr(qr_NEWENEMYTILES))
9861 {
9862 1940 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9863 1940 guysbuf[i].s_width=guysbuf[i].e_width;
9864 1940 guysbuf[i].s_height=guysbuf[i].e_height;
9865 1940 }
9866 405 else guysbuf[i].s_tile=860;
9867
9868
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2025 times.
2345 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9869 2025 guysbuf[i].flags &= ~guy_bkshield;
9870 else
9871 320 guysbuf[i].flags |= guy_bkshield;
9872 2345 }
9873
9874
4/4
✓ Branch 0 taken 82544 times.
✓ Branch 1 taken 469 times.
✓ Branch 2 taken 82963 times.
✓ Branch 3 taken 50 times.
83013 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9875 {
9876 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
9877 50 }
9878
9879 83013 guy_update_firesfx(guysbuf[i]);
9880 83013 guy_update_weaponflags(guysbuf[i]);
9881 83013 guy_update_weaponspecialsfx(guysbuf[i]);
9882 83013 }
9883 469 }
9884
9885 20992 void reset_weaponname(int32_t i)
9886 {
9887
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9888 {
9889 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9890 7216 }
9891 else
9892 13776 sprintf(weapon_string[i],"zz%03d",i);
9893 20992 }
9894
9895 469 void init_item_drop_sets()
9896 {
9897
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9898 {
9899 // item_drop_sets[i] = default_item_drop_sets[0];
9900 120064 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9901 120064 }
9902
9903
2/2
✓ Branch 0 taken 6097 times.
✓ Branch 1 taken 469 times.
6566 for(int32_t i=0; i<isMAX; i++)
9904 {
9905 6097 item_drop_sets[i] = default_item_drop_sets[i];
9906
9907 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9908
2/2
✓ Branch 0 taken 60970 times.
✓ Branch 1 taken 6097 times.
67067 for(int32_t j=0; j<10; ++j)
9909 {
9910 60970 int32_t it = item_drop_sets[i].item[j];
9911
9912
3/4
✓ Branch 0 taken 42872 times.
✓ Branch 1 taken 18098 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2766 times.
60970 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9913
2/2
✓ Branch 0 taken 2766 times.
✓ Branch 1 taken 40106 times.
42872 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9914 {
9915 2766 item_drop_sets[i].chance[j+1]=0;
9916 2766 }
9917
4/4
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 56328 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1732 times.
58204 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9918 {
9919 144 item_drop_sets[i].chance[j+1]=0;
9920 144 }
9921
9922 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9923
2/2
✓ Branch 0 taken 60946 times.
✓ Branch 1 taken 24 times.
60970 if(itemsbuf[it].family == itype_misc)
9924 {
9925 // If a non-gameplay item was selected, then item drop was aborted.
9926 // Reflect this by increasing the 'Nothing' chance accordingly.
9927 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9928 24 item_drop_sets[i].chance[j+1]=0;
9929 24 }
9930 60970 }
9931 6097 }
9932 469 }
9933
9934 469 void init_favorites()
9935 {
9936
2/2
✓ Branch 0 taken 590940 times.
✓ Branch 1 taken 469 times.
591409 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9937 {
9938 590940 favorite_combos[i]=-1;
9939 590940 }
9940 469 }
9941
9942 const char *ctype_name[cMAX]=
9943 {
9944 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9945 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9946 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9947 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9948 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9949 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9950 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9951 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9952 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9953 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9954 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9955 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9956 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9957 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9958 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9959 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9960 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9961 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9962 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9963 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9964 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9965 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9966 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9967 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9968 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9969 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9970 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9971 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9972
9973 };
9974
9975 761 int32_t init_combo_classes()
9976 {
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 761 times.
761 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9978
2/2
✓ Branch 0 taken 139263 times.
✓ Branch 1 taken 761 times.
140024 for(int32_t i=0; i<cMAX; i++)
9979 {
9980 139263 combo_class_buf[i] = default_combo_classes[i];
9981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139263 times.
139263 if ( char const* nm = zi->getComboTypeName(i) )
9982 {
9983 139263 size_t len = strlen(nm);
9984
2/2
✓ Branch 0 taken 8912832 times.
✓ Branch 1 taken 139263 times.
9052095 for ( size_t q = 0; q < 64; q++ )
9985 {
9986
2/2
✓ Branch 0 taken 2040241 times.
✓ Branch 1 taken 6872591 times.
8912832 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9987 8912832 }
9988 139263 }
9989 139263 }
9990
9991 761 return 0;
9992 }
9993
9994 310 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
9995 {
9996
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 264 times.
310 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if (should_skip) return 0;
9998
9999
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 assert(v_herosprites < 6);
10000
10001 310 zinit.hero_swim_speed=67; //default
10002 310 setupherotiles(zinit.heroAnimationStyle);
10003 310 setupherodefenses();
10004 310 setupherooffsets();
10005
10006
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 205 times.
310 if(v_herosprites>=0)
10007 {
10008 word tile, tile2;
10009 byte flip, extend, dummy_byte;
10010
10011
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10012 {
10013
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10014 {
10015 return qe_invalid;
10016 }
10017
10018
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10019 {
10020 return qe_invalid;
10021 }
10022
10023
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10024 {
10025 return qe_invalid;
10026 }
10027
10028 820 walkspr[i][spr_tile]=(int32_t)tile;
10029 820 walkspr[i][spr_flip]=(int32_t)flip;
10030 820 walkspr[i][spr_extend]=(int32_t)extend;
10031 820 }
10032
10033
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10034 {
10035
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10036 {
10037 return qe_invalid;
10038 }
10039
10040
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10041 {
10042 return qe_invalid;
10043 }
10044
10045
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10046 {
10047 return qe_invalid;
10048 }
10049
10050 820 stabspr[i][spr_tile]=(int32_t)tile;
10051 820 stabspr[i][spr_flip]=(int32_t)flip;
10052 820 stabspr[i][spr_extend]=(int32_t)extend;
10053 820 }
10054
10055
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10056 {
10057
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10058 {
10059 return qe_invalid;
10060 }
10061
10062
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10063 {
10064 return qe_invalid;
10065 }
10066
10067
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10068 {
10069 return qe_invalid;
10070 }
10071
10072 820 slashspr[i][spr_tile]=(int32_t)tile;
10073 820 slashspr[i][spr_flip]=(int32_t)flip;
10074 820 slashspr[i][spr_extend]=(int32_t)extend;
10075 820 }
10076
10077
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10078 {
10079
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10080 {
10081 return qe_invalid;
10082 }
10083
10084
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10085 {
10086 return qe_invalid;
10087 }
10088
10089
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10090 {
10091 return qe_invalid;
10092 }
10093
10094 820 floatspr[i][spr_tile]=(int32_t)tile;
10095 820 floatspr[i][spr_flip]=(int32_t)flip;
10096 820 floatspr[i][spr_extend]=(int32_t)extend;
10097 820 }
10098
10099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>1)
10100 {
10101
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10102 {
10103
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10104 {
10105 return qe_invalid;
10106 }
10107
10108
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10109 {
10110 return qe_invalid;
10111 }
10112
10113
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10114 {
10115 return qe_invalid;
10116 }
10117
10118 820 swimspr[i][spr_tile]=(int32_t)tile;
10119 820 swimspr[i][spr_flip]=(int32_t)flip;
10120 820 swimspr[i][spr_extend]=(int32_t)extend;
10121 820 }
10122 205 }
10123
10124
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10125 {
10126
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10127 {
10128 return qe_invalid;
10129 }
10130
10131
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10132 {
10133 return qe_invalid;
10134 }
10135
10136
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10137 {
10138 return qe_invalid;
10139 }
10140
10141 820 divespr[i][spr_tile]=(int32_t)tile;
10142 820 divespr[i][spr_flip]=(int32_t)flip;
10143 820 divespr[i][spr_extend]=(int32_t)extend;
10144 820 }
10145
10146
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10147 {
10148
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10149 {
10150 return qe_invalid;
10151 }
10152
10153
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10154 {
10155 return qe_invalid;
10156 }
10157
10158
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10159 {
10160 return qe_invalid;
10161 }
10162
10163 820 poundspr[i][spr_tile]=(int32_t)tile;
10164 820 poundspr[i][spr_flip]=(int32_t)flip;
10165 820 poundspr[i][spr_extend]=(int32_t)extend;
10166 820 }
10167
10168
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_igetw(&tile,f))
10169 {
10170 return qe_invalid;
10171 }
10172
10173 205 flip=0;
10174
10175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>0)
10176 {
10177
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&flip,f))
10178 {
10179 return qe_invalid;
10180 }
10181 205 }
10182
10183
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&extend,f))
10184 {
10185 return qe_invalid;
10186 }
10187
10188 205 castingspr[spr_tile]=(int32_t)tile;
10189 205 castingspr[spr_flip]=(int32_t)flip;
10190 205 castingspr[spr_extend]=(int32_t)extend;
10191
10192
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(v_herosprites>0)
10193 {
10194 205 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10195
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 205 times.
615 for(int32_t i=0; i<2; i++)
10196 {
10197
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 410 times.
1230 for(int32_t j=0; j<num_holdsprs; j++)
10198 {
10199
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10200 {
10201 return qe_invalid;
10202 }
10203
10204
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10210 {
10211 return qe_invalid;
10212 }
10213
10214 820 holdspr[i][j][spr_tile]=(int32_t)tile;
10215 820 holdspr[i][j][spr_flip]=(int32_t)flip;
10216 820 holdspr[i][j][spr_extend]=(int32_t)extend;
10217 820 }
10218 410 }
10219 205 }
10220 else
10221 {
10222 for(int32_t i=0; i<2; i++)
10223 {
10224 if(!p_igetw(&tile,f))
10225 {
10226 return qe_invalid;
10227 }
10228
10229 if(!p_igetw(&tile2,f))
10230 {
10231 return qe_invalid;
10232 }
10233
10234 if(!p_getc(&extend,f))
10235 {
10236 return qe_invalid;
10237 }
10238
10239 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10240 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10241 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10242 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10243 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10244 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10245 }
10246 }
10247
10248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>2)
10249 {
10250
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10251 {
10252
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10253 {
10254 return qe_invalid;
10255 }
10256
10257
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10258 {
10259 return qe_invalid;
10260 }
10261
10262
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&extend,f))
10263 {
10264 return qe_invalid;
10265 }
10266
10267 820 jumpspr[i][spr_tile]=(int32_t)tile;
10268 820 jumpspr[i][spr_flip]=(int32_t)flip;
10269 820 jumpspr[i][spr_extend]=(int32_t)extend;
10270 820 }
10271 205 }
10272
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>3)
10274 {
10275
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i=0; i<4; i++)
10276 {
10277
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_igetw(&tile,f))
10278 {
10279 return qe_invalid;
10280 }
10281
10282
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!p_getc(&flip,f))
10283 {
10284 return qe_invalid;
10285 }
10286
10287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(!p_getc(&extend,f))
10288 {
10289 return qe_invalid;
10290 }
10291
10292 820 chargespr[i][spr_tile]=(int32_t)tile;
10293 820 chargespr[i][spr_flip]=(int32_t)flip;
10294 820 chargespr[i][spr_extend]=(int32_t)extend;
10295 820 }
10296 205 }
10297
10298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(v_herosprites>4)
10299 {
10300
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&dummy_byte,f))
10301 {
10302 return qe_invalid;
10303 }
10304
10305 205 zinit.hero_swim_speed=(byte)dummy_byte;
10306 205 }
10307
10308 205 memset(frozenspr, 0, sizeof(frozenspr));
10309 205 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10310 205 memset(onfirespr, 0, sizeof(onfirespr));
10311 205 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10312 205 memset(diggingspr, 0, sizeof(diggingspr));
10313 205 memset(usingrodspr, 0, sizeof(usingrodspr));
10314 205 memset(usingcanespr, 0, sizeof(usingcanespr));
10315 205 memset(pushingspr, 0, sizeof(pushingspr));
10316 205 memset(liftingspr, 0, sizeof(liftingspr));
10317 205 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10318 205 memset(stunnedspr, 0, sizeof(stunnedspr));
10319 205 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10320 205 memset(fallingspr, 0, sizeof(fallingspr));
10321 205 memset(shockedspr, 0, sizeof(shockedspr));
10322 205 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10323 205 memset(pullswordspr, 0, sizeof(pullswordspr));
10324 205 memset(readingspr, 0, sizeof(readingspr));
10325 205 memset(slash180spr, 0, sizeof(slash180spr));
10326 205 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10327 205 memset(dashspr, 0, sizeof(dashspr));
10328 205 memset(bonkspr, 0, sizeof(bonkspr));
10329 205 memset(medallionsprs, 0, sizeof(medallionsprs));
10330 205 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10331 205 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10332
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t q = 0; q < 4; ++q)
10333 {
10334
2/2
✓ Branch 0 taken 2460 times.
✓ Branch 1 taken 820 times.
3280 for(int32_t p = 0; p < 3; ++p)
10335 {
10336 2460 drowningspr[q][p] = divespr[q][p];
10337 2460 drowning_lavaspr[q][p] = divespr[q][p];
10338 2460 }
10339 820 }
10340 205 memset(sideswimspr, 0, sizeof(sideswimspr));
10341 205 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10342 205 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10343 205 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10344 205 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10345 205 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10346 205 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10347 205 }
10348
10349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(FFCore.quest_format[vInitData] < 34)
10350 {
10351 310 bool fastswim = zinit.hero_swim_speed > 60;
10352 // '2/3' or '1/2'
10353 310 zinit.hero_swim_mult = fastswim ? 2 : 1;
10354 310 zinit.hero_swim_div = fastswim ? 3 : 2;
10355 310 }
10356 310 return 0;
10357 310 }
10358
10359 30940 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10360 {
10361 30940 arr[spr_tile] = tile;
10362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30940 times.
30940 arr[spr_flip] = (flip > 3 ? 0 : flip);
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30940 times.
30940 arr[spr_extend] = (ext > 2 ? 0 : ext);
10364 30940 }
10365 //Used to read the player sprites as int32_t, not word.
10366 182 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10367 {
10368 182 zinit.hero_swim_speed=67; //default
10369 182 setupherotiles(zinit.heroAnimationStyle);
10370 182 setupherodefenses();
10371 182 setupherooffsets();
10372
10373 int32_t tile, tile2;
10374 byte flip, extend, dummy_byte;
10375
10376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>=0)
10377 {
10378
10379
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10380 {
10381
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10382 {
10383 return qe_invalid;
10384 }
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10392 {
10393 return qe_invalid;
10394 }
10395
10396 728 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10397 728 }
10398
10399
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10400 {
10401
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10402 {
10403 return qe_invalid;
10404 }
10405
10406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10412 {
10413 return qe_invalid;
10414 }
10415
10416 728 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10417 728 }
10418
10419
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10420 {
10421
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10422 {
10423 return qe_invalid;
10424 }
10425
10426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10427 {
10428 return qe_invalid;
10429 }
10430
10431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10432 {
10433 return qe_invalid;
10434 }
10435
10436 728 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10437 728 }
10438
10439
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10440 {
10441
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10442 {
10443 return qe_invalid;
10444 }
10445
10446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10447 {
10448 return qe_invalid;
10449 }
10450
10451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10452 {
10453 return qe_invalid;
10454 }
10455
10456 728 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10457 728 }
10458
10459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>1)
10460 {
10461
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10462 {
10463
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10464 {
10465 return qe_invalid;
10466 }
10467
10468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10469 {
10470 return qe_invalid;
10471 }
10472
10473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10474 {
10475 return qe_invalid;
10476 }
10477
10478 728 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10479 728 }
10480 182 }
10481
10482
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10483 {
10484
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10485 {
10486 return qe_invalid;
10487 }
10488
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10490 {
10491 return qe_invalid;
10492 }
10493
10494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10495 {
10496 return qe_invalid;
10497 }
10498
10499 728 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10500 728 }
10501
10502
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10503 {
10504
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10505 {
10506 return qe_invalid;
10507 }
10508
10509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10510 {
10511 return qe_invalid;
10512 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10515 {
10516 return qe_invalid;
10517 }
10518
10519 728 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10520 728 }
10521
10522
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&tile,f))
10523 {
10524 return qe_invalid;
10525 }
10526
10527 182 flip=0;
10528
10529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>0)
10530 {
10531
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&flip,f))
10532 {
10533 return qe_invalid;
10534 }
10535 182 }
10536
10537
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&extend,f))
10538 {
10539 return qe_invalid;
10540 }
10541
10542 182 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10543
10544
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(v_herosprites>0)
10545 {
10546 182 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10547
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 182 times.
546 for(int32_t i=0; i<2; i++)
10548 {
10549
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 364 times.
1456 for(int32_t j=0; j<num_holdsprs; j++)
10550 {
10551
1/2
✓ Branch 0 taken 1092 times.
✗ Branch 1 not taken.
1092 if(!p_igetl(&tile,f))
10552 {
10553 return qe_invalid;
10554 }
10555
10556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if(!p_getc(&flip,f))
10557 {
10558 return qe_invalid;
10559 }
10560
10561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1092 times.
1092 if(!p_getc(&extend,f))
10562 {
10563 return qe_invalid;
10564 }
10565
10566 1092 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10567 1092 }
10568 364 }
10569 182 }
10570 else
10571 {
10572 for(int32_t i=0; i<2; i++)
10573 {
10574 if(!p_igetl(&tile,f))
10575 {
10576 return qe_invalid;
10577 }
10578
10579 if(!p_igetl(&tile2,f))
10580 {
10581 return qe_invalid;
10582 }
10583
10584 if(!p_getc(&extend,f))
10585 {
10586 return qe_invalid;
10587 }
10588
10589 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10590 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10591 }
10592 }
10593
10594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>2)
10595 {
10596
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10597 {
10598
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10599 {
10600 return qe_invalid;
10601 }
10602
10603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10604 {
10605 return qe_invalid;
10606 }
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10609 {
10610 return qe_invalid;
10611 }
10612
10613 728 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10614 728 }
10615 182 }
10616
10617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>3)
10618 {
10619
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t i=0; i<4; i++)
10620 {
10621
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10622 {
10623 return qe_invalid;
10624 }
10625
10626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10627 {
10628 return qe_invalid;
10629 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10632 {
10633 return qe_invalid;
10634 }
10635
10636 728 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10637 728 }
10638 182 }
10639
10640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 if(v_herosprites>4)
10641 {
10642
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&dummy_byte,f))
10643 {
10644 return qe_invalid;
10645 }
10646
10647 182 zinit.hero_swim_speed=(byte)dummy_byte;
10648 182 }
10649
10650
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(v_herosprites>6)
10651 {
10652
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10653 {
10654
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10655 return qe_invalid;
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10658 return qe_invalid;
10659
10660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10661 return qe_invalid;
10662
10663 728 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10664 728 }
10665
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10666 {
10667
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10668 return qe_invalid;
10669
10670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10671 return qe_invalid;
10672
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10674 return qe_invalid;
10675
10676 728 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10677 728 }
10678
10679
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10680 {
10681
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10682 return qe_invalid;
10683
10684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10685 return qe_invalid;
10686
10687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10688 return qe_invalid;
10689
10690 728 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10691 728 }
10692
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10693 {
10694
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10695 return qe_invalid;
10696
10697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10698 return qe_invalid;
10699
10700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10701 return qe_invalid;
10702
10703 728 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10704 728 }
10705
10706
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10707 {
10708
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10709 return qe_invalid;
10710
10711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10712 return qe_invalid;
10713
10714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10715 return qe_invalid;
10716
10717 728 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10718 728 }
10719
10720
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10721 {
10722
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10723 return qe_invalid;
10724
10725
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10726 return qe_invalid;
10727
10728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10729 return qe_invalid;
10730
10731 728 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10732 728 }
10733
10734
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10735 {
10736
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10737 return qe_invalid;
10738
10739
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10740 return qe_invalid;
10741
10742
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10743 return qe_invalid;
10744
10745 728 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10746 728 }
10747
10748
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10749 {
10750
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10751 return qe_invalid;
10752
10753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10754 return qe_invalid;
10755
10756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10757 return qe_invalid;
10758
10759 728 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10760 728 }
10761
10762
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10763 {
10764
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10765 return qe_invalid;
10766
10767
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10768 return qe_invalid;
10769
10770
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10771 return qe_invalid;
10772
10773 728 byte frames = 0;
10774
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 708 times.
728 if(v_herosprites > 15)
10775 {
10776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708 times.
708 if(!p_getc(&frames,f))
10777 return qe_invalid;
10778 708 }
10779
10780 728 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10781 728 liftingspr[q][spr_frames] = frames;
10782 728 }
10783
10784
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10785 {
10786
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10787 return qe_invalid;
10788
10789
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10790 return qe_invalid;
10791
10792
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10793 return qe_invalid;
10794
10795 728 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10796 728 }
10797
10798
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10799 {
10800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_igetl(&tile,f))
10801 return qe_invalid;
10802
10803
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10804 return qe_invalid;
10805
10806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10807 return qe_invalid;
10808
10809 728 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10810 728 }
10811
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10812 {
10813
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10814 return qe_invalid;
10815
10816
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10817 return qe_invalid;
10818
10819
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10820 return qe_invalid;
10821
10822 728 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10823 728 }
10824
10825
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10826 {
10827
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10828 return qe_invalid;
10829
10830
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10831 return qe_invalid;
10832
10833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10834 return qe_invalid;
10835
10836 728 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10837 728 }
10838
10839
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10840 {
10841
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10842 return qe_invalid;
10843
10844
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10845 return qe_invalid;
10846
10847
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10848 return qe_invalid;
10849
10850 728 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10851 728 }
10852
10853
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10854 {
10855
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10856 return qe_invalid;
10857
10858
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10859 return qe_invalid;
10860
10861
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10862 return qe_invalid;
10863
10864 728 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10865 728 }
10866
10867
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10868 {
10869
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10870 return qe_invalid;
10871
10872
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10873 return qe_invalid;
10874
10875
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10876 return qe_invalid;
10877
10878 728 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10879 728 }
10880
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10881 {
10882
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10883 return qe_invalid;
10884
10885
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10886 return qe_invalid;
10887
10888
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10889 return qe_invalid;
10890
10891 728 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10892 728 }
10893
10894
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10895 {
10896
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10897 return qe_invalid;
10898
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
10900 return qe_invalid;
10901
10902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10903 return qe_invalid;
10904
10905 728 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10906 728 }
10907
10908
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10909 {
10910
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10911 return qe_invalid;
10912
10913
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10914 return qe_invalid;
10915
10916
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10917 return qe_invalid;
10918
10919 728 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10920 728 }
10921
10922
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10923 {
10924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_igetl(&tile,f))
10925 return qe_invalid;
10926
10927
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10928 return qe_invalid;
10929
10930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
10931 return qe_invalid;
10932
10933 728 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10934 728 }
10935
10936
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10937 {
10938
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10939 return qe_invalid;
10940
10941
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10945 return qe_invalid;
10946
10947 728 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10948 728 }
10949
10950
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10951 {
10952
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10953 return qe_invalid;
10954
10955
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10956 return qe_invalid;
10957
10958
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10959 return qe_invalid;
10960
10961 728 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10962 728 }
10963
10964
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
10965 {
10966
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
10967 return qe_invalid;
10968
10969
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&flip,f))
10970 return qe_invalid;
10971
10972
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_getc(&extend,f))
10973 return qe_invalid;
10974
10975 728 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10976 728 }
10977
10978
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 182 times.
728 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10979 {
10980
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(!p_igetl(&tile,f))
10981 return qe_invalid;
10982
10983
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(!p_getc(&flip,f))
10984 return qe_invalid;
10985
10986
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(!p_getc(&extend,f))
10987 return qe_invalid;
10988
10989 546 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10990 546 }
10991 182 }
10992 else
10993 {
10994 memset(frozenspr, 0, sizeof(frozenspr));
10995 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10996 memset(onfirespr, 0, sizeof(onfirespr));
10997 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10998 memset(diggingspr, 0, sizeof(diggingspr));
10999 memset(usingrodspr, 0, sizeof(usingrodspr));
11000 memset(usingcanespr, 0, sizeof(usingcanespr));
11001 memset(pushingspr, 0, sizeof(pushingspr));
11002 memset(liftingspr, 0, sizeof(liftingspr));
11003 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11004 memset(stunnedspr, 0, sizeof(stunnedspr));
11005 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11006 memset(fallingspr, 0, sizeof(fallingspr));
11007 memset(shockedspr, 0, sizeof(shockedspr));
11008 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11009 memset(pullswordspr, 0, sizeof(pullswordspr));
11010 memset(readingspr, 0, sizeof(readingspr));
11011 memset(slash180spr, 0, sizeof(slash180spr));
11012 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11013 memset(dashspr, 0, sizeof(dashspr));
11014 memset(bonkspr, 0, sizeof(bonkspr));
11015 memset(medallionsprs, 0, sizeof(medallionsprs));
11016 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11017 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11018 for(int32_t q = 0; q < 4; ++q)
11019 {
11020 for(int32_t p = 0; p < 3; ++p)
11021 {
11022 drowningspr[q][p] = divespr[q][p];
11023 drowning_lavaspr[q][p] = divespr[q][p];
11024 }
11025 }
11026 }
11027
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 8)
11028 {
11029
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11030 {
11031
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11032 return qe_invalid;
11033
11034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11035 return qe_invalid;
11036
11037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11038 return qe_invalid;
11039
11040 728 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11041 728 }
11042 182 }
11043 else
11044 {
11045 memset(sideswimspr, 0, sizeof(sideswimspr));
11046 }
11047
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 9)
11048 {
11049
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11050 {
11051
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11058 return qe_invalid;
11059
11060 728 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11061 728 }
11062
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11063 {
11064
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11065 return qe_invalid;
11066
11067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11068 return qe_invalid;
11069
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11071 return qe_invalid;
11072
11073 728 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11074 728 }
11075
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11076 {
11077
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11078 return qe_invalid;
11079
11080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11081 return qe_invalid;
11082
11083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11084 return qe_invalid;
11085
11086 728 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11087 728 }
11088
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11089 {
11090
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11091 return qe_invalid;
11092
11093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11094 return qe_invalid;
11095
11096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11097 return qe_invalid;
11098
11099 728 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11100 728 }
11101 182 }
11102 else
11103 {
11104 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11105 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11106 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11107 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11108 }
11109
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 10)
11110 {
11111
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11112 {
11113 int32_t hmr;
11114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_igetl(&hmr,f))
11115 return qe_invalid;
11116
11117 728 hammeroffsets[q] = hmr;
11118 728 }
11119 182 }
11120 else
11121 {
11122 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11123 }
11124
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 11)
11125 {
11126
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 182 times.
728 for(int32_t q = 0; q < 3; ++q)
11127 {
11128
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if(!p_igetl(&tile,f))
11129 return qe_invalid;
11130
11131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if(!p_getc(&flip,f))
11132 return qe_invalid;
11133
11134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if(!p_getc(&extend,f))
11135 return qe_invalid;
11136
11137 546 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11138 546 }
11139 182 }
11140 else
11141 {
11142 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11143 }
11144
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 12)
11145 {
11146
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&tile,f))
11147 return qe_invalid;
11148
11149
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&flip,f))
11150 return qe_invalid;
11151
11152
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_getc(&extend,f))
11153 return qe_invalid;
11154 182 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11155
11156 182 }
11157 else
11158 {
11159 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11160 }
11161
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 13)
11162 {
11163
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11164 {
11165
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11166 return qe_invalid;
11167
11168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11169 return qe_invalid;
11170
11171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11172 return qe_invalid;
11173
11174 728 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11175 728 }
11176 182 }
11177 else
11178 {
11179 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11180 }
11181
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 14)
11182 {
11183
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 182 times.
910 for(int32_t q = 0; q < 4; ++q)
11184 {
11185
1/2
✓ Branch 0 taken 728 times.
✗ Branch 1 not taken.
728 if(!p_igetl(&tile,f))
11186 return qe_invalid;
11187
11188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&flip,f))
11189 return qe_invalid;
11190
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 if(!p_getc(&extend,f))
11192 return qe_invalid;
11193
11194 728 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11195 728 }
11196 182 }
11197 else
11198 {
11199 memset(revslashspr, 0, sizeof(revslashspr));
11200 }
11201
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if (v_herosprites > 7)
11202 {
11203 182 int32_t num_defense = wMax;
11204 182 byte def = 0;
11205
11206 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11207 /*if(v_herosprites > [x])
11208 * {
11209 * num_defense = 146 //value of wMax on version 8
11210 * }
11211 */
11212
11213
2/2
✓ Branch 0 taken 26572 times.
✓ Branch 1 taken 182 times.
26754 for (int32_t q = 0; q < num_defense; q++)
11214 {
11215
1/2
✓ Branch 0 taken 26572 times.
✗ Branch 1 not taken.
26572 if (!p_getc(&def, f))
11216 return qe_invalid;
11217
11218 26572 hero_defenses[q] = def;
11219 26572 }
11220 182 }
11221 else
11222 {
11223 int32_t num_defense = wMax;
11224 for (int32_t q = 0; q < num_defense; q++)
11225 {
11226 hero_defenses[q] = 0;
11227 }
11228 }
11229 182 }
11230
11231
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 11 times.
182 if(FFCore.quest_format[vInitData] < 34)
11232 {
11233 11 bool fastswim = zinit.hero_swim_speed > 60;
11234 // '2/3' or '1/2'
11235 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11236 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11237 11 }
11238 182 return 0;
11239 182 }
11240
11241
11242 387 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11243 {
11244 //these are here to bypass compiler warnings about unused arguments
11245 387 Header=Header;
11246
11247 dword dummy;
11248 387 word s_version=0;
11249
11250 //section version info
11251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
11252 {
11253 return qe_invalid;
11254 }
11255
11256 387 FFCore.quest_format[vHeroSprites] = s_version;
11257
11258
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
11259 {
11260 return qe_invalid;
11261 }
11262
11263 //section size
11264
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy,f))
11265 {
11266 return qe_invalid;
11267 }
11268
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if ( s_version >= 6 )
11269 {
11270 182 return readherosprites3(f, s_version);
11271 }
11272 205 else return readherosprites2(f, s_version);
11273 387 }
11274
11275 222 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11276 {
11277 222 subscreens_active.clear();
11278 222 subscreens_passive.clear();
11279 222 subscreens_overlay.clear();
11280
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 222 times.
28638 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11281 {
11282 subscreen_group g;
11283 28416 memset(&g,0,sizeof(subscreen_group));
11284 28416 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(ret!=0)
11286 return ret;
11287
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 27255 times.
28416 if(g.objects[0].type == ssoNULL) continue;
11288
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 676 times.
1161 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11289 1161 ZCSubscreen& sub = vec.emplace_back();
11290 1161 sub.load_old(g);
11291 1161 }
11292
11293 222 return 0;
11294 222 }
11295
11296 28416 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11297 {
11298 28416 int32_t numsub=0;
11299 28416 byte temp_ss=0;
11300 subscreen_object temp_sub_stack;
11301 28416 subscreen_object *temp_sub = &temp_sub_stack;
11302
11303 char tempname[64];
11304
11305 // FWIW I never saw anything bigger than 20.
11306 #define MAX_DP1_LEN 1024
11307 char tempdp1[MAX_DP1_LEN];
11308
11309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(!pfread(tempname,64,f))
11310 {
11311 return qe_invalid;
11312 }
11313
11314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(s_version > 1)
11315 {
11316
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if(!p_getc(&temp_ss,f))
11317 {
11318 return qe_invalid;
11319 }
11320 28416 }
11321
11322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28416 times.
28416 if(s_version < 4)
11323 {
11324 uint8_t tmp=0;
11325
11326 if(!p_getc(&tmp,f))
11327 {
11328 return qe_invalid;
11329 }
11330
11331 numsub = (int32_t)tmp;
11332 }
11333 else
11334 {
11335 word tmp;
11336
11337
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if(!p_igetw(&tmp, f))
11338 {
11339 return qe_invalid;
11340 }
11341
11342 28416 numsub = (int32_t)tmp;
11343 }
11344
11345 int32_t j;
11346
11347
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75277 times.
✓ Branch 2 taken 46861 times.
✓ Branch 3 taken 28416 times.
75277 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11348 {
11349 46861 memset(temp_sub,0,sizeof(subscreen_object));
11350
11351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46861 times.
46861 switch(g->objects[j].type)
11352 {
11353 case ssoTEXT:
11354 case ssoTEXTBOX:
11355 case ssoCURRENTITEMTEXT:
11356 case ssoCURRENTITEMCLASSTEXT:
11357 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11358
11359 //fall through
11360 default:
11361 46861 memset(&g->objects[j],0,sizeof(subscreen_object));
11362 46861 break;
11363 }
11364
11365
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->type),f))
11366 return qe_invalid;
11367
11368
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->pos),f))
11369 return qe_invalid;
11370
11371
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(s_version < 5)
11372 {
11373 switch(temp_sub->pos)
11374 {
11375 case 0:
11376 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11377 break;
11378
11379 case 1:
11380 temp_sub->pos = sspUP;
11381 break;
11382
11383 case 2:
11384 temp_sub->pos = sspDOWN;
11385 break;
11386
11387 default:
11388 temp_sub->pos = 0;
11389 }
11390 }
11391
11392
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->x),f))
11393 return qe_invalid;
11394
11395
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->y),f))
11396 return qe_invalid;
11397
11398
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->w),f))
11399 return qe_invalid;
11400
11401
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->h),f))
11402 return qe_invalid;
11403
11404
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype1),f))
11405 return qe_invalid;
11406
11407
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color1),f))
11408 return qe_invalid;
11409
11410
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype2),f))
11411 return qe_invalid;
11412
11413
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color2),f))
11414 return qe_invalid;
11415
11416
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->colortype3),f))
11417 return qe_invalid;
11418
11419
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->color3),f))
11420 return qe_invalid;
11421
11422
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d1),f))
11423 return qe_invalid;
11424
11425
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d2),f))
11426 return qe_invalid;
11427
11428
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d3),f))
11429 return qe_invalid;
11430
11431
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d4),f))
11432 return qe_invalid;
11433
11434
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d5),f))
11435 return qe_invalid;
11436
11437
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d6),f))
11438 return qe_invalid;
11439
11440
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d7),f))
11441 return qe_invalid;
11442
11443
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d8),f))
11444 return qe_invalid;
11445
11446
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d9),f))
11447 return qe_invalid;
11448
11449
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetd(&(temp_sub->d10),f))
11450 return qe_invalid;
11451
11452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46861 times.
46861 if(s_version < 2)
11453 {
11454 if(!p_igetl(&(temp_sub->speed),f))
11455 return qe_invalid;
11456
11457 if(!p_igetl(&(temp_sub->delay),f))
11458 return qe_invalid;
11459
11460 if(!p_igetl(&(temp_sub->frame),f))
11461 return qe_invalid;
11462 }
11463 else
11464 {
11465
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->speed),f))
11466 return qe_invalid;
11467
11468
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_getc(&(temp_sub->delay),f))
11469 return qe_invalid;
11470
11471
1/2
✓ Branch 0 taken 46861 times.
✗ Branch 1 not taken.
46861 if(!p_igetw(&(temp_sub->frame),f))
11472 return qe_invalid;
11473 }
11474
11475 46861 int32_t temp_size=0;
11476
11477 // bool deletets = false;
11478
4/4
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 3482 times.
✓ Branch 2 taken 22301 times.
✓ Branch 3 taken 250 times.
46861 switch(temp_sub->type)
11479 {
11480 case ssoTEXT:
11481 case ssoTEXTBOX:
11482 case ssoCURRENTITEMTEXT:
11483 case ssoCURRENTITEMCLASSTEXT:
11484 {
11485 word temptempsize;
11486
11487
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if(!p_igetw(&temptempsize,f))
11488 {
11489 return qe_invalid;
11490 }
11491
11492 //temptempsize = temp1 + (temp2 << 8);
11493 3482 temp_size = (int32_t)temptempsize;
11494 3482 uint32_t char_length = temp_size+2;
11495
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if (char_length > MAX_DP1_LEN)
11496 {
11497 return qe_invalid;
11498 }
11499 3482 tempdp1[char_length - 1] = '\0';
11500
11501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3482 times.
3482 if(temp_size)
11502
1/2
✓ Branch 0 taken 3482 times.
✗ Branch 1 not taken.
3482 if(!pfread(tempdp1,temp_size+1,f))
11503 return qe_invalid;
11504 3482 break;
11505 }
11506
11507 case ssoLIFEMETER:
11508
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11509 temp_sub->d3 = 1;
11510
11511
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(!p_getc(&(temp_sub->dp1),f))
11512 return qe_invalid;
11513
11514 250 break;
11515
11516
11517 case ssoCURRENTITEM:
11518
11519
1/2
✓ Branch 0 taken 20828 times.
✗ Branch 1 not taken.
20828 if(s_version < 6)
11520 {
11521 switch(temp_sub->d1)
11522 {
11523 case ssiBOMB:
11524 temp_sub->d1 = itype_bomb;
11525 break;
11526
11527 case ssiSWORD:
11528 temp_sub->d1 = itype_sword;
11529 break;
11530
11531 case ssiSHIELD:
11532 temp_sub->d1 = itype_shield;
11533 break;
11534
11535 case ssiCANDLE:
11536 temp_sub->d1 = itype_candle;
11537 break;
11538
11539 case ssiLETTER:
11540 temp_sub->d1 = itype_letter;
11541 break;
11542
11543 case ssiPOTION:
11544 temp_sub->d1 = itype_potion;
11545 break;
11546
11547 case ssiLETTERPOTION:
11548 temp_sub->d1 = itype_letterpotion;
11549 break;
11550
11551 case ssiBOW:
11552 temp_sub->d1 = itype_bow;
11553 break;
11554
11555 case ssiARROW:
11556 temp_sub->d1 = itype_arrow;
11557 break;
11558
11559 case ssiBOWANDARROW:
11560 temp_sub->d1 = itype_bowandarrow;
11561 break;
11562
11563 case ssiBAIT:
11564 temp_sub->d1 = itype_bait;
11565 break;
11566
11567 case ssiRING:
11568 temp_sub->d1 = itype_ring;
11569 break;
11570
11571 case ssiBRACELET:
11572 temp_sub->d1 = itype_bracelet;
11573 break;
11574
11575 case ssiMAP:
11576 temp_sub->d1 = itype_map;
11577 break;
11578
11579 case ssiCOMPASS:
11580 temp_sub->d1 = itype_compass;
11581 break;
11582
11583 case ssiBOSSKEY:
11584 temp_sub->d1 = itype_bosskey;
11585 break;
11586
11587 case ssiMAGICKEY:
11588 temp_sub->d1 = itype_magickey;
11589 break;
11590
11591 case ssiBRANG:
11592 temp_sub->d1 = itype_brang;
11593 break;
11594
11595 case ssiWAND:
11596 temp_sub->d1 = itype_wand;
11597 break;
11598
11599 case ssiRAFT:
11600 temp_sub->d1 = itype_raft;
11601 break;
11602
11603 case ssiLADDER:
11604 temp_sub->d1 = itype_ladder;
11605 break;
11606
11607 case ssiWHISTLE:
11608 temp_sub->d1 = itype_whistle;
11609 break;
11610
11611 case ssiBOOK:
11612 temp_sub->d1 = itype_book;
11613 break;
11614
11615 case ssiWALLET:
11616 temp_sub->d1 = itype_wallet;
11617 break;
11618
11619 case ssiSBOMB:
11620 temp_sub->d1 = itype_sbomb;
11621 break;
11622
11623 case ssiHCPIECE:
11624 temp_sub->d1 = itype_heartpiece;
11625 break;
11626
11627 case ssiAMULET:
11628 temp_sub->d1 = itype_amulet;
11629 break;
11630
11631 case ssiFLIPPERS:
11632 temp_sub->d1 = itype_flippers;
11633 break;
11634
11635 case ssiHOOKSHOT:
11636 temp_sub->d1 = itype_hookshot;
11637 break;
11638
11639 case ssiLENS:
11640 temp_sub->d1 = itype_lens;
11641 break;
11642
11643 case ssiHAMMER:
11644 temp_sub->d1 = itype_hammer;
11645 break;
11646
11647 case ssiBOOTS:
11648 temp_sub->d1 = itype_boots;
11649 break;
11650
11651 case ssiDIVINEFIRE:
11652 temp_sub->d1 = itype_divinefire;
11653 break;
11654
11655 case ssiDIVINEESCAPE:
11656 temp_sub->d1 = itype_divineescape;
11657 break;
11658
11659 case ssiDIVINEPROTECTION:
11660 temp_sub->d1 = itype_divineprotection;
11661 break;
11662
11663 case ssiQUIVER:
11664 temp_sub->d1 = itype_quiver;
11665 break;
11666
11667 case ssiBOMBBAG:
11668 temp_sub->d1 = itype_bombbag;
11669 break;
11670
11671 case ssiCBYRNA:
11672 temp_sub->d1 = itype_cbyrna;
11673 break;
11674
11675 case ssiROCS:
11676 temp_sub->d1 = itype_rocs;
11677 break;
11678
11679 case ssiHOVERBOOTS:
11680 temp_sub->d1 = itype_hoverboots;
11681 break;
11682
11683 case ssiSPINSCROLL:
11684 temp_sub->d1 = itype_spinscroll;
11685 break;
11686
11687 case ssiCROSSSCROLL:
11688 temp_sub->d1 = itype_crossscroll;
11689 break;
11690
11691 case ssiQUAKESCROLL:
11692 temp_sub->d1 = itype_quakescroll;
11693 break;
11694
11695 case ssiWHISPRING:
11696 temp_sub->d1 = itype_whispring;
11697 break;
11698
11699 case ssiCHARGERING:
11700 temp_sub->d1 = itype_chargering;
11701 break;
11702
11703 case ssiPERILSCROLL:
11704 temp_sub->d1 = itype_perilscroll;
11705 break;
11706
11707 case ssiWEALTHMEDAL:
11708 temp_sub->d1 = itype_wealthmedal;
11709 break;
11710
11711 case ssiHEARTRING:
11712 temp_sub->d1 = itype_heartring;
11713 break;
11714
11715 case ssiMAGICRING:
11716 temp_sub->d1 = itype_magicring;
11717 break;
11718
11719 case ssiSPINSCROLL2:
11720 temp_sub->d1 = itype_spinscroll2;
11721 break;
11722
11723 case ssiQUAKESCROLL2:
11724 temp_sub->d1 = itype_quakescroll2;
11725 break;
11726
11727 case ssiAGONY:
11728 temp_sub->d1 = itype_agony;
11729 break;
11730
11731 case ssiSTOMPBOOTS:
11732 temp_sub->d1 = itype_stompboots;
11733 break;
11734
11735 case ssiWHIMSICALRING:
11736 temp_sub->d1 = itype_whimsicalring;
11737 break;
11738
11739 case ssiPERILRING:
11740 temp_sub->d1 = itype_perilring;
11741 break;
11742
11743 default:
11744 temp_sub->d1 += itype_custom1 - ssiMAX;
11745 }
11746 }
11747
11748 //fall-through
11749 default:
11750
1/2
✓ Branch 0 taken 43129 times.
✗ Branch 1 not taken.
43129 if(!p_getc(&(temp_sub->dp1),f))
11751 return qe_invalid;
11752
11753 43129 break;
11754 }
11755
11756
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 38167 times.
46861 if(s_version < 7)
11757 {
11758
3/3
✓ Branch 0 taken 32010 times.
✓ Branch 1 taken 1389 times.
✓ Branch 2 taken 4768 times.
38167 switch(temp_sub->type)
11759 {
11760 case ssoMAGICGAUGE:
11761 {
11762
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1248 times.
1389 if(!temp_sub->d9)
11763 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11764 1389 break;
11765 }
11766 case ssoLIFEGAUGE:
11767 4768 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11768 4768 break;
11769 }
11770 38167 }
11771
11772
3/3
✓ Branch 0 taken 3482 times.
✓ Branch 1 taken 41785 times.
✓ Branch 2 taken 1594 times.
46861 switch(temp_sub->type)
11773 {
11774 case ssoTEXT:
11775 case ssoTEXTBOX:
11776 case ssoCURRENTITEMTEXT:
11777 case ssoCURRENTITEMCLASSTEXT:
11778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3482 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11779
11780 3482 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11781 3482 g->objects[j].dp1 = new char[temp_size+2];
11782 3482 strcpy((char*)g->objects[j].dp1,tempdp1);
11783 3482 break;
11784
11785 case ssoCOUNTER:
11786
1/2
✓ Branch 0 taken 1594 times.
✗ Branch 1 not taken.
1594 if(s_version<3)
11787 {
11788 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11789 temp_sub->d8=0;
11790 }
11791
11792 default:
11793 43379 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11794 43379 break;
11795 }
11796
11797 46861 g->name[0] = '\0';
11798 46861 strncat(g->name, tempname, 64 - 1);
11799 46861 g->ss_type = temp_ss;
11800 46861 }
11801
11802
2/2
✓ Branch 0 taken 7227635 times.
✓ Branch 1 taken 28416 times.
7256051 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11803 {
11804 //clear all unused object in this subscreen -DD
11805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7227635 times.
7227635 switch(g->objects[j].type)
11806 {
11807 case ssoTEXT:
11808 case ssoTEXTBOX:
11809 case ssoCURRENTITEMTEXT:
11810 case ssoCURRENTITEMCLASSTEXT:
11811 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11812
11813 //fall through
11814 default:
11815 7227635 memset(&g->objects[j],0,sizeof(subscreen_object));
11816 7227635 break;
11817 }
11818 7227635 }
11819
11820 28416 return 0;
11821 28416 }
11822
11823 387 int32_t readsubscreens(PACKFILE *f)
11824 {
11825 word s_version;
11826 dword dummy;
11827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
11828 return qe_invalid;
11829 387 FFCore.quest_format[vSubscreen] = s_version;
11830
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
11831 return qe_invalid;
11832
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy,f)) //section size
11833 return qe_invalid;
11834
11835
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 165 times.
387 if(s_version < 8)
11836 222 return read_old_subscreens(f,s_version);
11837
11838 165 subscreens_active.clear();
11839 165 subscreens_passive.clear();
11840 165 subscreens_overlay.clear();
11841
11842 byte sz;
11843
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&sz,f))
11844 return qe_invalid;
11845
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 165 times.
697 for(byte q = 0; q < sz; ++q)
11846 {
11847 532 ZCSubscreen& tmp = subscreens_active.emplace_back();
11848
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if (auto ret = tmp.read(f, s_version))
11849 return ret;
11850 532 }
11851
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&sz,f))
11852 return qe_invalid;
11853
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 165 times.
783 for(byte q = 0; q < sz; ++q)
11854 {
11855 618 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11856
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if (auto ret = tmp.read(f, s_version))
11857 return ret;
11858 618 }
11859
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&sz,f))
11860 return qe_invalid;
11861
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 165 times.
171 for(byte q = 0; q < sz; ++q)
11862 {
11863 6 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (auto ret = tmp.read(f, s_version))
11865 return ret;
11866 6 }
11867 165 return 0;
11868 387 }
11869
11870 void reset_subscreen(subscreen_group *tempss)
11871 {
11872 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11873 {
11874 switch(tempss->objects[i].type)
11875 {
11876 case ssoTEXT:
11877 case ssoTEXTBOX:
11878 case ssoCURRENTITEMTEXT:
11879 case ssoCURRENTITEMCLASSTEXT:
11880 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11881
11882 //fall through
11883 default:
11884 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11885 break;
11886 }
11887 }
11888 }
11889
11890 116 void reset_subscreens()
11891 {
11892 116 subscreens_active.clear();
11893 116 subscreens_passive.clear();
11894 116 subscreens_overlay.clear();
11895 116 }
11896
11897 116 int32_t setupsubscreens()
11898 {
11899 116 reset_subscreens();
11900 //return 0;
11901
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 232 times.
348 for(int q = 0; q < 2; ++q)
11902 {
11903 232 subscreens_active.emplace_back();
11904 232 subscreens_passive.emplace_back();
11905 232 }
11906 116 int32_t tempsubscreen=subscr_mode;
11907
11908
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(tempsubscreen>=ssdtMAX)
11909 tempsubscreen=0;
11910
11911
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
116 switch(tempsubscreen)
11912 {
11913 case ssdtOLD:
11914 case ssdtNEWSUBSCR:
11915 case ssdtREV2:
11916 case ssdtBSZELDA:
11917 case ssdtBSZELDAMODIFIED:
11918 case ssdtBSZELDAENHANCED:
11919 case ssdtBSZELDACOMPLETE:
11920 {
11921 116 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11922 116 subscreens_active[0].sub_type=sstACTIVE;
11923 116 subscreens_active[0].name = "Active Subscreen (Triforce)";
11924 116 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11925 116 subscreens_active[1].sub_type=sstACTIVE;
11926 116 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11927 116 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11928 116 subscreens_passive[0].sub_type=sstPASSIVE;
11929 116 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11930 116 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11931 116 subscreens_passive[1].sub_type=sstPASSIVE;
11932 116 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11933 116 break;
11934 }
11935
11936 case ssdtZ3:
11937 {
11938 subscreens_active[0].load_old(z3_active_a);
11939 subscreens_active[0].sub_type=sstACTIVE;
11940 subscreens_active[1].load_old(z3_active_ab);
11941 subscreens_active[1].sub_type=sstACTIVE;
11942 subscreens_passive[0].load_old(z3_passive_a);
11943 subscreens_passive[0].sub_type=sstPASSIVE;
11944 subscreens_passive[1].load_old(z3_passive_ab);
11945 subscreens_passive[1].sub_type=sstPASSIVE;
11946 break;
11947 }
11948 }
11949 116 subscr_mode = ssdtMAX;
11950 116 return 0;
11951 }
11952
11953 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
11954
11955 extern script_data *ffscripts[NUMSCRIPTFFC];
11956 extern script_data *itemscripts[NUMSCRIPTITEM];
11957 extern script_data *guyscripts[NUMSCRIPTGUYS];
11958 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11959 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11960 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11961 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11962 extern script_data *playerscripts[NUMSCRIPTHERO];
11963 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11964 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11965 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11966 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11967 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11968
11969 static std::vector<const script_data*> read_scripts;
11970
11971 416 static script_data fake_script_data(ScriptType::None, 0);
11972
11973 463 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11974 {
11975 int32_t dummy;
11976 463 word s_version=0, zmeta_version=0;
11977 463 byte numscripts=0;
11978 463 numscripts=numscripts; //to avoid unused variables warnings
11979 int32_t ret;
11980 463 read_scripts.clear();
11981 463 zasm_scripts.clear();
11982
11983 //section version info
11984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if(!p_igetw(&s_version,f))
11985 {
11986 return qe_invalid;
11987 }
11988
11989 463 FFCore.quest_format[vFFScript] = s_version;
11990
11991
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 if(!read_deprecated_section_cversion(f))
11992 {
11993 return qe_invalid;
11994 }
11995
11996
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 182 times.
463 if(s_version >= 18)
11997 {
11998
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetw(&zmeta_version,f))
11999 {
12000 return qe_invalid;
12001 }
12002 182 }
12003
12004 //section size
12005
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 if(!p_igetl(&dummy,f))
12006 {
12007 return qe_invalid;
12008 }
12009
12010
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 224 times.
463 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12011 463 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12012
12013
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 116 times.
463 if(s_version >= 27)
12014 {
12015 116 ret = read_quest_zasm(f, s_version);
12016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(ret)
12017 return qe_invalid;
12018 116 }
12019
12020 //finally... section data
12021
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 417 times.
198561 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12022 {
12023 198144 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12024
12025
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if (ret)
12026 {
12027 return qe_invalid;
12028 }
12029 198144 }
12030
12031 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12032 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12033 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12034 * there was a version bump a week before a change that broke stuff.
12035 */
12036
7/8
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 235 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
✓ Branch 4 taken 182 times.
✓ Branch 5 taken 182 times.
✓ Branch 6 taken 182 times.
✓ Branch 7 taken 182 times.
417 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12037 {
12038 599 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12039 599 }
12040
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(s_version < 19)
12041 {
12042 205 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12043 205 }
12044
12045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version > 1)
12046 {
12047
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12048 {
12049 99072 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12050
12051
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if (ret)
12052 {
12053 return qe_invalid;
12054 }
12055 99072 }
12056
12057
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12058 {
12059 99072 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12060
12061
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if (ret)
12062 {
12063 return qe_invalid;
12064 }
12065 99072 }
12066
12067
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12068 {
12069 99072 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12070
12071
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if (ret)
12072 {
12073 return qe_invalid;
12074 }
12075 99072 }
12076
12077
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 387 times.
99459 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12078 {
12079 99072 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12080
12081
1/2
✓ Branch 0 taken 99072 times.
✗ Branch 1 not taken.
99072 if (ret)
12082 {
12083 return qe_invalid;
12084 }
12085 99072 }
12086
12087
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(s_version > 16)
12088 {
12089
2/2
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 182 times.
1638 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12090 {
12091 1456 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12092
12093
1/2
✓ Branch 0 taken 1456 times.
✗ Branch 1 not taken.
1456 if (ret)
12094 {
12095 return qe_invalid;
12096 }
12097 1456 }
12098 182 }
12099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 else if(s_version > 13)
12100 {
12101 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12102 {
12103 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12104
12105 if (ret)
12106 {
12107 return qe_invalid;
12108 }
12109 }
12110
12111 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12112 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12113
12114 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12115 }
12116
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 else if(s_version > 4)
12117 {
12118
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 205 times.
1025 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12119 {
12120 820 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12121
12122
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if (ret)
12123 {
12124 return qe_invalid;
12125 }
12126 820 }
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12129
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12130
12131
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12132
12133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12134
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12135
12136
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12137
12138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12139
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_F6];
12140
12141
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12142
12143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12144
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12145
12146
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12147 205 }
12148 else
12149 {
12150 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12151 {
12152 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12153
12154 if (ret)
12155 {
12156 return qe_invalid;
12157 }
12158 }
12159
12160 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12161 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12162
12163 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12164
12165 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12166 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12167
12168 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12169
12170 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12171 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12172
12173 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12174
12175 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12176 delete globalscripts[GLOBAL_SCRIPT_F6];
12177
12178 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12179
12180 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12181 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12182
12183 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12184 }
12185
12186
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(s_version > 10) //expanded the number of Hero scripts to 5.
12187 {
12188
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 182 times.
1092 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12189 {
12190 910 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12191
12192
1/2
✓ Branch 0 taken 910 times.
✗ Branch 1 not taken.
910 if (ret)
12193 {
12194 return qe_invalid;
12195 }
12196 910 }
12197 182 }
12198 else
12199 {
12200
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 205 times.
820 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12201 {
12202 615 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12203
12204
1/2
✓ Branch 0 taken 615 times.
✗ Branch 1 not taken.
615 if (ret)
12205 {
12206 return qe_invalid;
12207 }
12208 615 }
12209
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(playerscripts[3] != NULL)
12210
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 delete playerscripts[3];
12211
12212
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12213
12214
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(playerscripts[4] != NULL)
12215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 delete playerscripts[4];
12216
12217
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12218 }
12219
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
387 if(s_version > 8 && s_version < 10)
12220 {
12221
12222 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12223 {
12224 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12225
12226 if (ret)
12227 {
12228 return qe_invalid;
12229 }
12230 }
12231 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12232 {
12233 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12234
12235 if (ret)
12236 {
12237 return qe_invalid;
12238 }
12239 }
12240
12241 }
12242
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >= 10)
12243 {
12244
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12245 {
12246 46592 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12247
12248
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (ret)
12249 {
12250 return qe_invalid;
12251 }
12252 46592 }
12253
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12254 {
12255 46592 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12256
12257
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (ret)
12258 {
12259 return qe_invalid;
12260 }
12261 46592 }
12262
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12263 {
12264 46592 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12265
12266
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (ret)
12267 {
12268 return qe_invalid;
12269 }
12270 46592 }
12271
12272 182 }
12273
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >=12)
12274 {
12275
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 182 times.
46774 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12276 {
12277 46592 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12278
12279
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 if (ret)
12280 {
12281 return qe_invalid;
12282 }
12283 46592 }
12284 182 }
12285
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >=15)
12286 {
12287
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 182 times.
93366 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12288 {
12289 93184 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12290
12291
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if (ret)
12292 {
12293 return qe_invalid;
12294 }
12295 93184 }
12296 182 }
12297
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >19)
12298 {
12299 182 word numgenscripts = NUMSCRIPTSGENERIC;
12300
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetw(&numgenscripts,f))
12301 {
12302 return qe_invalid;
12303 }
12304
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 182 times.
93366 for(int32_t i = 0; i < numgenscripts; i++)
12305 {
12306 93184 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12307
12308
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if (ret)
12309 {
12310 return qe_invalid;
12311 }
12312 93184 }
12313 182 }
12314
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 165 times.
387 if(s_version >21)
12315 {
12316 165 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12317
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_igetw(&numsubscripts,f))
12318 {
12319 return qe_invalid;
12320 }
12321
2/2
✓ Branch 0 taken 42240 times.
✓ Branch 1 taken 165 times.
42405 for(int32_t i = 0; i < numsubscripts; i++)
12322 {
12323 42240 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12324
12325
1/2
✓ Branch 0 taken 42240 times.
✗ Branch 1 not taken.
42240 if (ret)
12326 {
12327 return qe_invalid;
12328 }
12329 42240 }
12330 165 }
12331 387 }
12332
12333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version > 2)
12334 {
12335 int32_t bufsize;
12336 387 p_igetl(&bufsize, f);
12337
2/4
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
387 if (bufsize < 0 || bufsize > 1024*1024*10)
12338 {
12339 // God help anyone storing more than 10MB of code in the script buffer.
12340 return qe_invalid;
12341 }
12342 387 char * buf = new char[bufsize+1];
12343 387 pfread(buf, bufsize, f);
12344 387 buf[bufsize]=0;
12345
12346
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 zScript = string(buf);
12347
12348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 delete[] buf;
12349 word numffcbindings;
12350 387 p_igetw(&numffcbindings, f);
12351
12352
2/2
✓ Branch 0 taken 10354 times.
✓ Branch 1 taken 387 times.
10741 for(int32_t i=0; i<numffcbindings; i++)
12353 {
12354 word id;
12355 10354 p_igetw(&id, f);
12356 10354 p_igetl(&bufsize, f);
12357
2/4
✓ Branch 0 taken 10354 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10354 times.
10354 if (bufsize < 0 || bufsize > 1024)
12358 return qe_invalid;
12359 10354 buf = new char[bufsize+1];
12360 10354 pfread(buf, bufsize, f);
12361 10354 buf[bufsize]=0;
12362
12363 //fix for buggy older saved quests -DD
12364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10354 times.
10354 if(id < NUMSCRIPTFFC-1)
12365 10354 ffcmap[id].scriptname = buf;
12366
12367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10354 times.
10354 delete[] buf;
12368 10354 }
12369
12370 word numglobalbindings;
12371 387 p_igetw(&numglobalbindings, f);
12372
12373
2/2
✓ Branch 0 taken 1578 times.
✓ Branch 1 taken 387 times.
1965 for(int32_t i=0; i<numglobalbindings; i++)
12374 {
12375 word id;
12376 1578 p_igetw(&id, f);
12377 1578 p_igetl(&bufsize, f);
12378
2/4
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1578 times.
✗ Branch 3 not taken.
1578 if (bufsize < 0 || bufsize > 1024)
12379 return qe_invalid;
12380 1578 buf = new char[bufsize+1];
12381 1578 pfread(buf, bufsize, f);
12382 1578 buf[bufsize]=0;
12383
12384 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12385 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12386 // Ignore these. -DD
12387
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 1020 times.
1578 if (id < NUMSCRIPTGLOBAL)
12388 {
12389 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12390
1/2
✓ Branch 0 taken 1020 times.
✗ Branch 1 not taken.
1020 if(strcmp(buf,"~Continue") == 0)
12391 {
12392 globalmap[id].scriptname = "";
12393
12394 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12395 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12396 }
12397 else
12398 {
12399 1020 globalmap[id].scriptname = buf;
12400 }
12401 1020 }
12402
12403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1578 times.
1578 delete[] buf;
12404 1578 }
12405
12406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version > 3)
12407 {
12408 word numitembindings;
12409 387 p_igetw(&numitembindings, f);
12410
12411
2/2
✓ Branch 0 taken 1299 times.
✓ Branch 1 taken 387 times.
1686 for(int32_t i=0; i<numitembindings; i++)
12412 {
12413 word id;
12414 1299 p_igetw(&id, f);
12415 1299 p_igetl(&bufsize, f);
12416
2/4
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1299 times.
1299 if (bufsize < 0 || bufsize > 1024)
12417 return qe_invalid;
12418 1299 buf = new char[bufsize+1];
12419 1299 pfread(buf, bufsize, f);
12420 1299 buf[bufsize]=0;
12421
12422 //fix this too
12423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1299 times.
1299 if(id <NUMSCRIPTITEM-1)
12424 1299 itemmap[id].scriptname = buf;
12425
12426
1/2
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
1299 delete[] buf;
12427 1299 }
12428 387 }
12429 //(v9+)
12430
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version > 8)
12431 {
12432 //npc scripts
12433 word numnpcbindings;
12434 182 p_igetw(&numnpcbindings, f);
12435
12436
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 182 times.
214 for(int32_t i=0; i<numnpcbindings; i++)
12437 {
12438 word id;
12439 32 p_igetw(&id, f);
12440 32 p_igetl(&bufsize, f);
12441
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12442 return qe_invalid;
12443 32 buf = new char[bufsize+1];
12444 32 pfread(buf, bufsize, f);
12445 32 buf[bufsize]=0;
12446
12447 //fix this too
12448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTGUYS-1)
12449 32 npcmap[id].scriptname = buf;
12450
12451
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 delete[] buf;
12452 32 }
12453 //lweapon
12454 word numlwpnbindings;
12455 182 p_igetw(&numlwpnbindings, f);
12456
12457
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 182 times.
506 for(int32_t i=0; i<numlwpnbindings; i++)
12458 {
12459 word id;
12460 324 p_igetw(&id, f);
12461 324 p_igetl(&bufsize, f);
12462
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 324 times.
324 if (bufsize < 0 || bufsize > 1024)
12463 return qe_invalid;
12464 324 buf = new char[bufsize+1];
12465 324 pfread(buf, bufsize, f);
12466 324 buf[bufsize]=0;
12467
12468 //fix this too
12469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324 times.
324 if(id <NUMSCRIPTWEAPONS-1)
12470 324 lwpnmap[id].scriptname = buf;
12471
12472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 324 times.
324 delete[] buf;
12473 324 }
12474 //eweapon
12475 word numewpnbindings;
12476 182 p_igetw(&numewpnbindings, f);
12477
12478
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 182 times.
479 for(int32_t i=0; i<numewpnbindings; i++)
12479 {
12480 word id;
12481 297 p_igetw(&id, f);
12482 297 p_igetl(&bufsize, f);
12483
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if (bufsize < 0 || bufsize > 1024)
12484 return qe_invalid;
12485 297 buf = new char[bufsize+1];
12486 297 pfread(buf, bufsize, f);
12487 297 buf[bufsize]=0;
12488
12489 //fix this too
12490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(id <NUMSCRIPTWEAPONS-1)
12491 297 ewpnmap[id].scriptname = buf;
12492
12493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 delete[] buf;
12494 297 }
12495 //hero
12496 word numherobindings;
12497 182 p_igetw(&numherobindings, f);
12498
12499
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 182 times.
205 for(int32_t i=0; i<numherobindings; i++)
12500 {
12501 word id;
12502 23 p_igetw(&id, f);
12503 23 p_igetl(&bufsize, f);
12504
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12505 return qe_invalid;
12506 23 buf = new char[bufsize+1];
12507 23 pfread(buf, bufsize, f);
12508 23 buf[bufsize]=0;
12509
12510 //fix this too
12511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTHERO-1)
12512 23 playermap[id].scriptname = buf;
12513
12514
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12515 23 }
12516 //dmaps
12517 word numdmapbindings;
12518 182 p_igetw(&numdmapbindings, f);
12519
12520
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 182 times.
596 for(int32_t i=0; i<numdmapbindings; i++)
12521 {
12522 word id;
12523 414 p_igetw(&id, f);
12524 414 p_igetl(&bufsize, f);
12525
2/4
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 414 times.
414 if (bufsize < 0 || bufsize > 1024)
12526 return qe_invalid;
12527 414 buf = new char[bufsize+1];
12528 414 pfread(buf, bufsize, f);
12529 414 buf[bufsize]=0;
12530
12531 //fix this too
12532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
414 if(id <NUMSCRIPTSDMAP-1)
12533 414 dmapmap[id].scriptname = buf;
12534
12535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 414 times.
414 delete[] buf;
12536 414 }
12537 //screen
12538 word numscreenbindings;
12539 182 p_igetw(&numscreenbindings, f);
12540
12541
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 182 times.
588 for(int32_t i=0; i<numscreenbindings; i++)
12542 {
12543 word id;
12544 406 p_igetw(&id, f);
12545 406 p_igetl(&bufsize, f);
12546
2/4
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
406 if (bufsize < 0 || bufsize > 1024)
12547 return qe_invalid;
12548 406 buf = new char[bufsize+1];
12549 406 pfread(buf, bufsize, f);
12550 406 buf[bufsize]=0;
12551
12552 //fix this too
12553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(id <NUMSCRIPTSDMAP-1)
12554 406 screenmap[id].scriptname = buf;
12555
12556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 delete[] buf;
12557 406 }
12558 182 }
12559
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version > 11)
12560 {
12561 word numspritebindings;
12562 182 p_igetw(&numspritebindings, f);
12563
12564
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 182 times.
231 for(int32_t i=0; i<numspritebindings; i++)
12565 {
12566 word id;
12567 49 p_igetw(&id, f);
12568 49 p_igetl(&bufsize, f);
12569
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
49 if (bufsize < 0 || bufsize > 1024)
12570 return qe_invalid;
12571 49 buf = new char[bufsize+1];
12572 49 pfread(buf, bufsize, f);
12573 49 buf[bufsize]=0;
12574
12575 //fix this too
12576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(id <NUMSCRIPTSDMAP-1)
12577 49 itemspritemap[id].scriptname = buf;
12578
12579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 delete[] buf;
12580 49 }
12581 182 }
12582
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version >= 15)
12583 {
12584 word numcombobindings;
12585 182 p_igetw(&numcombobindings, f);
12586
12587
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 182 times.
339 for(int32_t i=0; i<numcombobindings; i++)
12588 {
12589 word id;
12590 157 p_igetw(&id, f);
12591 157 p_igetl(&bufsize, f);
12592
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
157 if (bufsize < 0 || bufsize > 1024)
12593 return qe_invalid;
12594 157 buf = new char[bufsize+1];
12595 157 pfread(buf, bufsize, f);
12596 157 buf[bufsize]=0;
12597
12598 //fix this too
12599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(id <NUMSCRIPTSCOMBODATA-1)
12600 157 comboscriptmap[id].scriptname = buf;
12601
12602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 delete[] buf;
12603 157 }
12604 182 }
12605
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if(s_version > 19)
12606 {
12607 word numgenericbindings;
12608 182 p_igetw(&numgenericbindings, f);
12609
12610
2/2
✓ Branch 0 taken 1543 times.
✓ Branch 1 taken 182 times.
1725 for(int32_t i=0; i<numgenericbindings; i++)
12611 {
12612 word id;
12613 1543 p_igetw(&id, f);
12614 1543 p_igetl(&bufsize, f);
12615
2/4
✓ Branch 0 taken 1543 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1543 times.
✗ Branch 3 not taken.
1543 if (bufsize < 0 || bufsize > 1024)
12616 return qe_invalid;
12617 1543 buf = new char[bufsize+1];
12618 1543 pfread(buf, bufsize, f);
12619 1543 buf[bufsize]=0;
12620
12621 //fix this too
12622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1543 times.
1543 if(id <NUMSCRIPTSGENERIC-1)
12623 1543 genericmap[id].scriptname = buf;
12624
12625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1543 times.
1543 delete[] buf;
12626 1543 }
12627 182 }
12628
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 165 times.
387 if(s_version > 21)
12629 {
12630 word numsubscreenbindings;
12631 165 p_igetw(&numsubscreenbindings, f);
12632
12633
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 165 times.
173 for(int32_t i=0; i<numsubscreenbindings; i++)
12634 {
12635 word id;
12636 8 p_igetw(&id, f);
12637 8 p_igetl(&bufsize, f);
12638
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (bufsize < 0 || bufsize > 1024)
12639 return qe_invalid;
12640 8 buf = new char[bufsize+1];
12641 8 pfread(buf, bufsize, f);
12642 8 buf[bufsize]=0;
12643
12644 //fix this too
12645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(id <NUMSCRIPTSSUBSCREEN-1)
12646 8 subscreenmap[id].scriptname = buf;
12647
12648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 delete[] buf;
12649 8 }
12650 165 }
12651 387 }
12652
12653 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12654 // This is only updated when the scripts have been recompiled.
12655 // They should all match each other.
12656 387 std::optional<word> zscript_version;
12657
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 182 times.
387 if (s_version >= 16)
12658 {
12659
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 6357 times.
6537 for (auto script : read_scripts)
12660 {
12661
2/2
✓ Branch 0 taken 6355 times.
✓ Branch 1 taken 2 times.
6357 if (script->meta.ffscript_v == 0)
12662 {
12663 // These scripts were saved in a version prior to this field being set.
12664 // See https://discord.com/channels/876899628556091432/1368485306394738718
12665 2 zscript_version = 16;
12666 2 break;
12667 }
12668
1/2
✓ Branch 0 taken 6355 times.
✗ Branch 1 not taken.
6355 if (script->meta.ffscript_v > s_version)
12669 break;
12670
12671
2/2
✓ Branch 0 taken 6192 times.
✓ Branch 1 taken 163 times.
6355 if (!zscript_version.has_value())
12672 {
12673 163 zscript_version = script->meta.ffscript_v;
12674 163 continue;
12675 }
12676
12677
1/2
✓ Branch 0 taken 6192 times.
✗ Branch 1 not taken.
6192 if (zscript_version.value() != script->meta.ffscript_v)
12678 {
12679 zscript_version.reset();
12680 break;
12681 }
12682 }
12683
12684
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 17 times.
182 if (!zscript_version.has_value())
12685 17 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12686 182 }
12687 387 setZScriptVersion(zscript_version.value_or(s_version));
12688 387 read_scripts.clear();
12689
12690 387 return 0;
12691 387 }
12692
12693 void(*reset_scripts_hook)();
12694
12695 469 void reset_scripts()
12696 {
12697 // We can't modify the script data while jit threads are possibly compiling them.
12698
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 458 times.
469 if (reset_scripts_hook)
12699 458 reset_scripts_hook();
12700
12701
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12702 {
12703
1/2
✓ Branch 0 taken 240128 times.
✗ Branch 1 not taken.
240128 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12704 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12705 240128 }
12706
12707
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12708 {
12709
1/2
✓ Branch 0 taken 240128 times.
✗ Branch 1 not taken.
240128 if (ffscripts[i])
12710 240128 ffscripts[i]->disable();
12711 else
12712 ffscripts[i] = new script_data(ScriptType::FFC, i);
12713 240128 }
12714
12715
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12716 {
12717
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (itemscripts[i])
12718 120064 itemscripts[i]->disable();
12719 else
12720 itemscripts[i] = new script_data(ScriptType::Item, i);
12721 120064 }
12722
12723
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12724 {
12725
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (guyscripts[i])
12726 120064 guyscripts[i]->disable();
12727 else
12728 guyscripts[i] = new script_data(ScriptType::NPC, i);
12729 120064 }
12730
12731
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12732 {
12733
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (screenscripts[i])
12734 120064 screenscripts[i]->disable();
12735 else
12736 screenscripts[i] = new script_data(ScriptType::Screen, i);
12737 120064 }
12738
12739
2/2
✓ Branch 0 taken 3752 times.
✓ Branch 1 taken 469 times.
4221 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12740 {
12741
1/2
✓ Branch 0 taken 3752 times.
✗ Branch 1 not taken.
3752 if (globalscripts[i])
12742 3752 globalscripts[i]->disable();
12743 else
12744 globalscripts[i] = new script_data(ScriptType::Global, i);
12745 3752 }
12746
12747
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 469 times.
2814 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12748 {
12749
1/2
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
2345 if (playerscripts[i])
12750 2345 playerscripts[i]->disable();
12751 else
12752 playerscripts[i] = new script_data(ScriptType::Hero, i);
12753 2345 }
12754
12755
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12756 {
12757
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (lwpnscripts[i])
12758 120064 lwpnscripts[i]->disable();
12759 else
12760 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12761 120064 }
12762
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12763 {
12764
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (ewpnscripts[i])
12765 120064 ewpnscripts[i]->disable();
12766 else
12767 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12768 120064 }
12769
12770
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12771 {
12772
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (dmapscripts[i])
12773 120064 dmapscripts[i]->disable();
12774 else
12775 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12776 120064 }
12777
2/2
✓ Branch 0 taken 120064 times.
✓ Branch 1 taken 469 times.
120533 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12778 {
12779
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (itemspritescripts[i])
12780 120064 itemspritescripts[i]->disable();
12781 else
12782 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12783 120064 }
12784
2/2
✓ Branch 0 taken 240128 times.
✓ Branch 1 taken 469 times.
240597 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12785 {
12786
1/2
✓ Branch 0 taken 240128 times.
✗ Branch 1 not taken.
240128 if (comboscripts[i])
12787 240128 comboscripts[i]->disable();
12788 else
12789 comboscripts[i] = new script_data(ScriptType::Combo, i);
12790 240128 }
12791
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 120064 times.
120533 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12792 {
12793
1/2
✓ Branch 0 taken 120064 times.
✗ Branch 1 not taken.
120064 if (subscreenscripts[i])
12794 120064 subscreenscripts[i]->disable();
12795 else
12796 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12797 120064 }
12798 469 }
12799
12800 // 3.0+ calls this.
12801 116 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12802 {
12803 int32_t num_commands;
12804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!p_igetl(&num_commands,f))
12805 return qe_invalid;
12806 #ifdef ZC_FUZZ
12807 const int32_t command_limit = 300000;
12808 #else
12809 116 const int32_t command_limit = 25000000;
12810 #endif
12811
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
116 if (num_commands < 0 || num_commands > command_limit)
12812 return qe_invalid;
12813
12814 116 std::vector<ffscript> zasm;
12815
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 zasm.reserve(num_commands);
12816
2/2
✓ Branch 0 taken 2919590 times.
✓ Branch 1 taken 116 times.
2919706 for(int32_t j=0; j<num_commands; j++)
12817 {
12818
1/2
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
2919590 ffscript temp_script;
12819
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetw(&(temp_script.command),f))
12820 return qe_invalid;
12821
12822
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&(temp_script.arg1),f))
12823 return qe_invalid;
12824
12825
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&(temp_script.arg2),f))
12826 return qe_invalid;
12827
12828
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&(temp_script.arg3),f))
12829 return qe_invalid;
12830
12831 2919590 uint32_t sz = 0;
12832
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&sz,f))
12833 return qe_invalid;
12834
2/2
✓ Branch 0 taken 28939 times.
✓ Branch 1 taken 2890651 times.
2919590 if(sz) //string found
12835 {
12836
1/2
✓ Branch 0 taken 28939 times.
✗ Branch 1 not taken.
28939 temp_script.strptr = new std::string();
12837 char dummy;
12838
2/2
✓ Branch 0 taken 494335 times.
✓ Branch 1 taken 28939 times.
523274 for(size_t q = 0; q < sz; ++q)
12839 {
12840
2/4
✓ Branch 0 taken 494335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494335 times.
✗ Branch 3 not taken.
494335 if(!p_getc(&dummy,f))
12841 return qe_invalid;
12842
1/2
✓ Branch 0 taken 494335 times.
✗ Branch 1 not taken.
494335 temp_script.strptr->push_back(dummy);
12843 494335 }
12844 28939 }
12845
2/4
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2919590 times.
✗ Branch 3 not taken.
2919590 if(!p_igetl(&sz,f))
12846 return qe_invalid;
12847
2/2
✓ Branch 0 taken 3459 times.
✓ Branch 1 taken 2916131 times.
2919590 if(sz) //vector found
12848 {
12849
1/2
✓ Branch 0 taken 3459 times.
✗ Branch 1 not taken.
3459 temp_script.vecptr = new std::vector<int32_t>();
12850 int32_t dummy;
12851
2/2
✓ Branch 0 taken 11560 times.
✓ Branch 1 taken 3459 times.
15019 for(size_t q = 0; q < sz; ++q)
12852 {
12853
2/4
✓ Branch 0 taken 11560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11560 times.
✗ Branch 3 not taken.
11560 if(!p_igetl(&dummy,f))
12854 return qe_invalid;
12855
1/2
✓ Branch 0 taken 11560 times.
✗ Branch 1 not taken.
11560 temp_script.vecptr->push_back(dummy);
12856 11560 }
12857 3459 }
12858
1/2
✓ Branch 0 taken 2919590 times.
✗ Branch 1 not taken.
2919590 zasm.emplace_back(std::move(temp_script));
12859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2919590 times.
2919590 }
12860
12861
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 assert(zasm_scripts.empty());
12862 116 zasm_script_id id = zasm_scripts.size();
12863
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
116 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
12864
12865 116 return 0;
12866 116 }
12867
12868 1013209 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12869 {
12870 ASSERT(script);
12871
2/2
✓ Branch 0 taken 566261 times.
✓ Branch 1 taken 446948 times.
1013209 if(s_version < 27)
12872 566261 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
12873
12874 char exists;
12875
1/2
✓ Branch 0 taken 446948 times.
✗ Branch 1 not taken.
446948 if (!p_getc(&exists, f))
12876 return qe_invalid;
12877
2/2
✓ Branch 0 taken 3313 times.
✓ Branch 1 taken 443635 times.
446948 if (!exists)
12878 {
12879 443635 script->disable();
12880 443635 return 0;
12881 }
12882
12883 //Read meta
12884 {
12885 3313 zasm_meta temp_meta;
12886
12887
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.zasm_v),f))
12888 return qe_invalid;
12889
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.meta_v),f))
12890 return qe_invalid;
12891
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.ffscript_v),f))
12892 return qe_invalid;
12893
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_getc(&(temp_meta.script_type),f))
12894 return qe_invalid;
12895
12896
2/2
✓ Branch 0 taken 26504 times.
✓ Branch 1 taken 3313 times.
29817 for(int32_t q = 0; q < 8; ++q)
12897 {
12898
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getcstr(&temp_meta.run_idens[q],f))
12899 return qe_invalid;
12900 26504 }
12901
12902
2/2
✓ Branch 0 taken 3313 times.
✓ Branch 1 taken 26504 times.
29817 for(int32_t q = 0; q < 8; ++q)
12903
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getc(&(temp_meta.run_types[q]),f))
12904 return qe_invalid;
12905
12906
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_getc(&(temp_meta.flags),f))
12907 return qe_invalid;
12908
12909
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.compiler_v1),f))
12910 return qe_invalid;
12911
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.compiler_v2),f))
12912 return qe_invalid;
12913
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.compiler_v3),f))
12914 return qe_invalid;
12915
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_igetw(&(temp_meta.compiler_v4),f))
12916 return qe_invalid;
12917
12918
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_getcstr(&temp_meta.script_name,f))
12919 return qe_invalid;
12920
2/4
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
✗ Branch 3 not taken.
3313 if(!p_getcstr(&temp_meta.author,f))
12921 return qe_invalid;
12922 3313 auto num_meta_attrib = 10;
12923
2/2
✓ Branch 0 taken 33130 times.
✓ Branch 1 taken 3313 times.
36443 for(auto q = 0; q < num_meta_attrib; ++q)
12924 {
12925
2/4
✓ Branch 0 taken 33130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33130 times.
✗ Branch 3 not taken.
33130 if(!p_getcstr(&temp_meta.attributes[q],f))
12926 return qe_invalid;
12927
2/4
✓ Branch 0 taken 33130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33130 times.
✗ Branch 3 not taken.
33130 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12928 return qe_invalid;
12929 33130 }
12930
2/2
✓ Branch 0 taken 26504 times.
✓ Branch 1 taken 3313 times.
29817 for(auto q = 0; q < 8; ++q)
12931 {
12932
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getcstr(&temp_meta.attribytes[q],f))
12933 return qe_invalid;
12934
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12935 return qe_invalid;
12936 26504 }
12937
2/2
✓ Branch 0 taken 26504 times.
✓ Branch 1 taken 3313 times.
29817 for(auto q = 0; q < 8; ++q)
12938 {
12939
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12940 return qe_invalid;
12941
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12942 return qe_invalid;
12943 26504 }
12944
2/2
✓ Branch 0 taken 53008 times.
✓ Branch 1 taken 3313 times.
56321 for(auto q = 0; q < 16; ++q)
12945 {
12946
2/4
✓ Branch 0 taken 53008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53008 times.
✗ Branch 3 not taken.
53008 if(!p_getcstr(&temp_meta.usrflags[q],f))
12947 return qe_invalid;
12948
2/4
✓ Branch 0 taken 53008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53008 times.
✗ Branch 3 not taken.
53008 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12949 return qe_invalid;
12950 53008 }
12951
2/2
✓ Branch 0 taken 26504 times.
✓ Branch 1 taken 3313 times.
29817 for(auto q = 0; q < 8; ++q)
12952 {
12953
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getcstr(&temp_meta.initd[q],f))
12954 return qe_invalid;
12955
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getwstr(&temp_meta.initd_help[q],f))
12956 return qe_invalid;
12957 26504 }
12958
2/2
✓ Branch 0 taken 3313 times.
✓ Branch 1 taken 26504 times.
29817 for(auto q = 0; q < 8; ++q)
12959 {
12960
2/4
✓ Branch 0 taken 26504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26504 times.
✗ Branch 3 not taken.
26504 if(!p_getc(&temp_meta.initd_type[q],f))
12961 return qe_invalid;
12962 26504 }
12963
12964
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 script->meta = temp_meta;
12965
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3313 times.
3313 }
12966
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 if(!p_igetl(&script->pc, f))
12967 return qe_invalid;
12968
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 if(!p_igetl(&script->end_pc, f))
12969 return qe_invalid;
12970
12971
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 if (script == &fake_script_data)
12972 return 0;
12973
12974
1/2
✓ Branch 0 taken 3313 times.
✗ Branch 1 not taken.
3313 assert(zasm_scripts.size() == 1);
12975 3313 auto& zs = zasm_scripts[0];
12976 3313 script->zasm_script = zs;
12977
12978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3313 times.
3313 if (script->valid())
12979 {
12980 3313 zs->script_datas.push_back(script);
12981 3313 read_scripts.push_back(script);
12982 3313 }
12983
12984 3313 return 0;
12985 1013209 }
12986
12987 566261 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12988 {
12989 566261 char b33[34] = {0};
12990 566261 b33[33] = 0;
12991 566261 int32_t num_commands=1000;
12992
12993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 566261 times.
566261 if(s_version>=2)
12994 {
12995
1/2
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
566261 if(!p_igetl(&num_commands,f))
12996 {
12997 return qe_invalid;
12998 }
12999 566261 }
13000
13001 #ifdef ZC_FUZZ
13002 const int32_t command_limit = 300000;
13003 #else
13004 566261 const int32_t command_limit = 10000000;
13005 #endif
13006
2/4
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 566261 times.
566261 if (num_commands < 0 || num_commands > command_limit)
13007 {
13008 return qe_invalid;
13009 }
13010
13011 566261 std::vector<ffscript> zasm;
13012
1/2
✓ Branch 0 taken 566261 times.
✗ Branch 1 not taken.
566261 zasm.reserve(num_commands);
13013
13014
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 316315 times.
566261 if(s_version >= 16)
13015 {
13016
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
13017
13018
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
13019 {
13020 return qe_invalid;
13021 }
13022
13023
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
13024 {
13025 return qe_invalid;
13026 }
13027
13028
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13029 {
13030 return qe_invalid;
13031 }
13032
13033
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13034 {
13035 return qe_invalid;
13036 }
13037
13038
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13039 {
13040
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13041 {
13042
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13043 {
13044
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13045 {
13046 return qe_invalid;
13047 }
13048 4748040 }
13049
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13050 143880 }
13051 else
13052 {
13053
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13054 {
13055 return qe_invalid;
13056 }
13057 }
13058 1999568 }
13059
13060
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13061 {
13062
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13063 {
13064 return qe_invalid;
13065 }
13066 1999568 }
13067
13068
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13069 {
13070 return qe_invalid;
13071 }
13072
13073
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13074 {
13075 return qe_invalid;
13076 }
13077
13078
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13079 {
13080 return qe_invalid;
13081 }
13082
13083
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13084 {
13085 return qe_invalid;
13086 }
13087
13088
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13089 {
13090 return qe_invalid;
13091 }
13092
13093
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13094 {
13095
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13096 {
13097
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13098 {
13099 return qe_invalid;
13100 }
13101 593505 }
13102
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13103
13104
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13105 {
13106
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13107 {
13108 return qe_invalid;
13109 }
13110 593505 }
13111
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13112 17985 }
13113
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13114 {
13115
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13116 return qe_invalid;
13117
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13118 return qe_invalid;
13119 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13120
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13121 {
13122
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13123 return qe_invalid;
13124
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13125 return qe_invalid;
13126 2319610 }
13127
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13128 {
13129
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13130 return qe_invalid;
13131
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13132 return qe_invalid;
13133 1855688 }
13134
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13135 {
13136
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13137 return qe_invalid;
13138
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13139 return qe_invalid;
13140 1855688 }
13141
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13142 {
13143
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13144 return qe_invalid;
13145
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13146 return qe_invalid;
13147 3711376 }
13148 231961 }
13149
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13150 {
13151
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13152 {
13153
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13154 return qe_invalid;
13155
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13156 return qe_invalid;
13157 1855688 }
13158
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13159 {
13160
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13161 return qe_invalid;
13162 1855688 }
13163 231961 }
13164 else
13165 {
13166
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13167 {
13168
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13169 143880 }
13170 }
13171
13172
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13173
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 316315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 316315 times.
✗ Branch 5 not taken.
566261 } else script->meta = {};
13174
13175
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 107364918 times.
107439592 for(int32_t j=0; j<num_commands; j++)
13176 {
13177
1/2
✓ Branch 0 taken 107364918 times.
✗ Branch 1 not taken.
107364918 auto& sc = zasm.emplace_back();
13178
2/4
✓ Branch 0 taken 107364918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107364918 times.
✗ Branch 3 not taken.
107364918 if(!p_igetw(&sc.command,f))
13179 {
13180 return qe_invalid;
13181 }
13182
13183
2/2
✓ Branch 0 taken 106873331 times.
✓ Branch 1 taken 491587 times.
107364918 if(sc.command == 0xFFFF)
13184 491587 break;
13185 else
13186 {
13187
2/4
✓ Branch 0 taken 106873331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106873331 times.
✗ Branch 3 not taken.
106873331 if(!p_igetl(&sc.arg1,f))
13188 {
13189 return qe_invalid;
13190 }
13191
13192
2/4
✓ Branch 0 taken 106873331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106873331 times.
✗ Branch 3 not taken.
106873331 if(!p_igetl(&sc.arg2,f))
13193 {
13194 return qe_invalid;
13195 }
13196
13197
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 105825584 times.
106873331 if(s_version >= 24)
13198
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13199 return qe_invalid;
13200
13201
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 98651294 times.
106873331 if(s_version >= 21)
13202 {
13203 8222037 uint32_t sz = 0;
13204
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13205 {
13206 return qe_invalid;
13207 }
13208
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13209 {
13210
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13211 char dummy;
13212
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13213 {
13214
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13215 {
13216 return qe_invalid;
13217 }
13218
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13219 1165008 }
13220 19400 }
13221
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13222 {
13223 return qe_invalid;
13224 }
13225
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13226 {
13227
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13228 int32_t dummy;
13229
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13230 {
13231
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13232 {
13233 return qe_invalid;
13234 }
13235
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13236 11526 }
13237 933 }
13238 8222037 }
13239 }
13240 106873331 }
13241
13242
2/2
✓ Branch 0 taken 496885 times.
✓ Branch 1 taken 69376 times.
566261 if (script == &fake_script_data)
13243 69376 return 0;
13244
13245 // If the first command is unknown, invalidate the whole thing.
13246 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13247
5/6
✓ Branch 0 taken 427587 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 415407 times.
✓ Branch 3 taken 12180 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 415407 times.
496885 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13248 {
13249 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13250 zasm.clear();
13251 }
13252
13253 496885 zasm_script_id id = zasm_scripts.size();
13254
3/6
✓ Branch 0 taken 496885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 496885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 496885 times.
✗ Branch 5 not taken.
496885 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13255 496885 script->zasm_script = zs;
13256 496885 script->pc = 0;
13257 496885 script->end_pc = zs->size;
13258
3/4
✓ Branch 0 taken 496885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12180 times.
✓ Branch 3 taken 484705 times.
496885 if (script->valid())
13259 {
13260
1/2
✓ Branch 0 taken 12180 times.
✗ Branch 1 not taken.
12180 zs->script_datas.push_back(script);
13261
1/2
✓ Branch 0 taken 12180 times.
✗ Branch 1 not taken.
12180 read_scripts.push_back(script);
13262 12180 }
13263
13264 496885 return 0;
13265 566261 }
13266
13267 extern SAMPLE customsfxdata[WAV_COUNT];
13268 extern uint8_t customsfxflag[WAV_COUNT>>3];
13269 extern int32_t sfxdat;
13270 extern DATAFILE *sfxdata;
13271 const char *old_sfx_string[Z35] =
13272 {
13273 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13274 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13275 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13276 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13277 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13278 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13279 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13280 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13281 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13282 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13283 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13284 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13285 };
13286 char *sfx_string[WAV_COUNT];
13287
13288 387 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13289 {
13290 //these are here to bypass compiler warnings about unused arguments
13291 387 Header=Header;
13292
13293 int32_t dummy;
13294 387 word s_version=0;
13295 //int32_t ret;
13296 387 SAMPLE temp_sample = {};
13297 387 temp_sample.loop_start=0;
13298 387 temp_sample.loop_end=0;
13299 387 temp_sample.param=0;
13300
13301 //section version info
13302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&s_version,f))
13303 {
13304 return qe_invalid;
13305 }
13306
13307 387 FFCore.quest_format[vSFX] = s_version;
13308
13309
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
13310 {
13311 return qe_invalid;
13312 }
13313
13314 //section size
13315
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy,f))
13316 {
13317 return qe_invalid;
13318 }
13319
13320 /* HIGHLY UNORTHODOX UPDATING THING, by L
13321 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13322 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13323 * changing from 1 to 2.
13324 */
13325
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version < 2)
13326 set_qr(qr_GOTOLESSNOTEQUAL,1);
13327
13328 /* End highly unorthodox updating thing */
13329
13330 387 int32_t wavcount = WAV_COUNT;
13331
13332
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version < 6)
13333 wavcount = 128;
13334
13335 uint8_t tempflag[WAV_COUNT>>3];
13336
13337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version < 4)
13338 {
13339 memset(tempflag, 0xFF, WAV_COUNT>>3);
13340 }
13341 else
13342 {
13343
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version < 6)
13344 memset(tempflag, 0, WAV_COUNT>>3);
13345
13346
2/2
✓ Branch 0 taken 12384 times.
✓ Branch 1 taken 387 times.
12771 for(int32_t i=0; i<(wavcount>>3); i++)
13347 {
13348 12384 p_getc(&tempflag[i], f);
13349 12384 }
13350
13351 }
13352
13353
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(s_version>4)
13354 {
13355
2/2
✓ Branch 0 taken 98685 times.
✓ Branch 1 taken 387 times.
99072 for(int32_t i=1; i<WAV_COUNT; i++)
13356 {
13357 98685 sprintf(sfx_string[i],"s%03d",i);
13358
13359
2/2
✓ Branch 0 taken 75465 times.
✓ Branch 1 taken 23220 times.
98685 if((i<Z35))
13360 23220 strcpy(sfx_string[i], old_sfx_string[i-1]);
13361
13362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98685 times.
98685 if(i>=wavcount)
13363 continue;
13364
2/2
✓ Branch 0 taken 19851 times.
✓ Branch 1 taken 78834 times.
98685 if(get_bit(tempflag, i-1))
13365 {
13366 char tempname[36];
13367
13368
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!pfread(tempname, 36, f))
13369 {
13370 return qe_invalid;
13371 }
13372
13373 19851 sfx_string[i][0] = '\0';
13374 19851 strncat(sfx_string[i], tempname, 36 - 1);
13375 19851 }
13376 else
13377 {
13378 78834 sprintf(sfx_string[i],"s%03d",i);
13379
13380
2/2
✓ Branch 0 taken 68932 times.
✓ Branch 1 taken 9902 times.
78834 if(i<Z35)
13381 9902 strcpy(sfx_string[i], old_sfx_string[i-1]);
13382 78834 sfx_string[i][35] = 0; //Force NULL Termination
13383 }
13384 98685 }
13385 387 }
13386 else
13387 {
13388 for(int32_t i=1; i<WAV_COUNT; i++)
13389 {
13390 sprintf(sfx_string[i],"s%03d",i);
13391
13392 if(i<Z35)
13393 strcpy(sfx_string[i], old_sfx_string[i-1]);
13394 }
13395 }
13396
13397 //finally... section data
13398
2/2
✓ Branch 0 taken 98685 times.
✓ Branch 1 taken 387 times.
99072 for(int32_t i=1; i<wavcount; i++)
13399 {
13400
2/2
✓ Branch 0 taken 19851 times.
✓ Branch 1 taken 78834 times.
98685 if(get_bit(tempflag, i-1))
13401 {
13402
13403
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&dummy,f))
13404 {
13405 return qe_invalid;
13406 }
13407
13408 19851 (temp_sample.bits) = dummy;
13409
13410
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&dummy,f))
13411 {
13412 return qe_invalid;
13413 }
13414
13415 19851 (temp_sample.stereo) = dummy;
13416
13417
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&dummy,f))
13418 {
13419 return qe_invalid;
13420 }
13421
13422 19851 (temp_sample.freq) = dummy;
13423
13424
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&dummy,f))
13425 {
13426 return qe_invalid;
13427 }
13428
13429 19851 (temp_sample.priority) = dummy;
13430
13431
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&(temp_sample.len),f))
13432 {
13433 return qe_invalid;
13434 }
13435
13436
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&(temp_sample.loop_start),f))
13437 {
13438 return qe_invalid;
13439 }
13440
13441
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&(temp_sample.loop_end),f))
13442 {
13443 return qe_invalid;
13444 }
13445
13446
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(!p_igetl(&(temp_sample.param),f))
13447 {
13448 return qe_invalid;
13449 }
13450
13451 19851 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13452 #ifdef ZC_FUZZ
13453 const int32_t sfx_limit = 100000;
13454 if (len < 0 || len > sfx_limit)
13455 {
13456 return qe_invalid;
13457 }
13458 #endif
13459 19851 temp_sample.data = calloc(len,1);
13460
13461
1/2
✓ Branch 0 taken 19851 times.
✗ Branch 1 not taken.
19851 if(s_version < 3)
13462 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13463
13464 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19851 times.
19851 if(s_version < 2)
13466 {
13467 if(!pfread(temp_sample.data, len,f))
13468 {
13469 return qe_invalid;
13470 }
13471 }
13472 else
13473 {
13474 //re-endianfy the data
13475 19851 int32_t wordstoread = len / sizeof(word);
13476
13477
2/2
✓ Branch 0 taken 551768152 times.
✓ Branch 1 taken 19851 times.
551788003 for(int32_t j=0; j<wordstoread; j++)
13478 {
13479 word temp;
13480
13481
1/2
✓ Branch 0 taken 551768152 times.
✗ Branch 1 not taken.
551768152 if(!p_igetw(&temp, f))
13482 {
13483 return qe_invalid;
13484 }
13485
13486 551768152 ((word *)temp_sample.data)[j] = temp;
13487 551768152 }
13488 }
13489 19851 }
13490
2/2
✓ Branch 0 taken 9902 times.
✓ Branch 1 taken 68932 times.
78834 else if(i < Z35)
13491 {
13492 9902 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13493 9902 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13494 9902 set_bit(tempflag, i-1, 1);
13495 9902 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13496 9902 temp_sample.data = calloc(len,1);
13497 9902 memcpy(temp_sample.data, datsamp->data, len);
13498 9902 }
13499 68932 else continue;
13500
13501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29753 times.
29753 if(customsfxdata[i].data!=NULL)
13502 {
13503 // delete [] customsfxdata[i].data;
13504 29753 free(customsfxdata[i].data);
13505 29753 }
13506
13507 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13508 29753 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13509 29753 customsfxdata[i].data = calloc(len2,1);
13510 29753 customsfxdata[i].bits = temp_sample.bits;
13511 29753 customsfxdata[i].stereo = temp_sample.stereo;
13512 29753 customsfxdata[i].freq = temp_sample.freq;
13513 29753 customsfxdata[i].priority = temp_sample.priority;
13514 29753 customsfxdata[i].len = temp_sample.len;
13515 29753 customsfxdata[i].loop_start = temp_sample.loop_start;
13516 29753 customsfxdata[i].loop_end = temp_sample.loop_end;
13517 29753 customsfxdata[i].param = temp_sample.param;
13518 29753 int32_t cpylen = len2;
13519
13520
1/2
✓ Branch 0 taken 29753 times.
✗ Branch 1 not taken.
29753 if(s_version<3)
13521 {
13522 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13523 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13524 }
13525
13526 29753 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13527
13528 29753 free(temp_sample.data);
13529 29753 }
13530
13531 387 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13532
13533 387 sfxdat=0;
13534 387 return 0;
13535 387 }
13536
13537 469 void setupsfx()
13538 {
13539
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=1; i<WAV_COUNT; i++)
13540 {
13541 119595 sprintf(sfx_string[i],"s%03d",i);
13542
13543
2/2
✓ Branch 0 taken 91455 times.
✓ Branch 1 taken 28140 times.
119595 if(i<Z35)
13544 {
13545 28140 strcpy(sfx_string[i], old_sfx_string[i-1]);
13546 28140 }
13547
13548 119595 memset(customsfxflag, 0, WAV_COUNT>>3);
13549
13550 119595 int32_t j=i;
13551
13552
2/2
✓ Branch 0 taken 28609 times.
✓ Branch 1 taken 90986 times.
119595 if(i>Z35)
13553 {
13554 90986 i=Z35;
13555 90986 }
13556
13557 119595 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13558
13559
2/2
✓ Branch 0 taken 92565 times.
✓ Branch 1 taken 27030 times.
119595 if(customsfxdata[j].data!=NULL)
13560 {
13561 // delete [] customsfxdata[j].data;
13562 27030 free(customsfxdata[j].data);
13563 27030 }
13564
13565 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13566 119595 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13567 119595 customsfxdata[j].bits = temp_sample->bits;
13568 119595 customsfxdata[j].stereo = temp_sample->stereo;
13569 119595 customsfxdata[j].freq = temp_sample->freq;
13570 119595 customsfxdata[j].priority = temp_sample->priority;
13571 119595 customsfxdata[j].len = temp_sample->len;
13572 119595 customsfxdata[j].loop_start = temp_sample->loop_start;
13573 119595 customsfxdata[j].loop_end = temp_sample->loop_end;
13574 119595 customsfxdata[j].param = temp_sample->param;
13575 119595 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13576 119595 i=j;
13577 119595 }
13578 469 }
13579
13580 extern char *guy_string[eMAXGUYS];
13581 extern const char *old_guy_string[OLDMAXGUYS];
13582
13583 469 int32_t readguys(PACKFILE *f, zquestheader *Header)
13584 {
13585
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (should_skip) return 0;
13587
13588 dword dummy;
13589 word guy_cversion;
13590 469 word guyversion=0;
13591
13592
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if(Header->zelda_version >= 0x193)
13593 {
13594 //section version info
13595
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&guyversion,f))
13596 {
13597 return qe_invalid;
13598 }
13599
13600 446 FFCore.quest_format[vGuys] = guyversion;
13601
13602 // Note: this is the only instance where "cversion" is ever used.
13603
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&guy_cversion,f))
13604 {
13605 return qe_invalid;
13606 }
13607
13608 //section size
13609
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
13610 {
13611 return qe_invalid;
13612 }
13613 446 }
13614
13615
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
469 if(guyversion > 3)
13616 {
13617
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 387 times.
198531 for(int32_t i=0; i<MAXGUYS; i++)
13618 {
13619 char tempname[64];
13620
13621 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13622 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13623
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198144 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13624 {
13625 memset(tempname, 0, sizeof(char)*64);
13626 sprintf(tempname, "e%03d", i);
13627 strcpy(guy_string[i], tempname);
13628
13629 continue;
13630 }
13631
13632
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!pfread(tempname, 64, f))
13633 {
13634 return qe_invalid;
13635 }
13636
13637 // Don't retain names of uneditable enemy entries!
13638 // for version upgrade to 2.5
13639
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198144 if(guyversion < 23 && i >= 177)
13640 {
13641 // some of the older builds have names such as 'zz123',
13642 // (this order gets messed up with some eXXX and some zzXXX)
13643 // so let's update to the newer naming convection. -Gleeok
13644 char tmpbuf[64];
13645 memset(tmpbuf, 0, sizeof(char)*64);
13646 sprintf(tmpbuf, "zz%03d", i);
13647
13648 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13649 {
13650 memset(tempname, 0, sizeof(char)*64);
13651 sprintf(tempname, "e%03d", i);
13652 }
13653 }
13654
13655
6/6
✓ Branch 0 taken 68499 times.
✓ Branch 1 taken 129645 times.
✓ Branch 2 taken 65016 times.
✓ Branch 3 taken 3483 times.
✓ Branch 4 taken 56346 times.
✓ Branch 5 taken 8670 times.
198144 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13656 {
13657 189474 guy_string[i][0] = '\0';
13658 189474 strncat(guy_string[i], tempname, 64 - 1);
13659 189474 }
13660 else
13661 {
13662 8670 strcpy(guy_string[i],old_guy_string[i]);
13663 }
13664 198144 }
13665 387 }
13666 else
13667 {
13668
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13669 {
13670 41984 sprintf(guy_string[i],"zz%03d",i);
13671 41984 }
13672
13673
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13674 {
13675 14514 strcpy(guy_string[i],old_guy_string[i]);
13676 14514 }
13677 }
13678
13679
13680 //finally... section data
13681 469 init_guys(guyversion); //using default data for now...
13682
13683 // Goriya guy fix
13684
3/6
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
469 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13685 {
13686
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13687 {
13688 60 guysbuf[gGORIYA].tile=130;
13689 60 guysbuf[gGORIYA].e_tile=130;
13690 60 }
13691 82 }
13692
13693
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 if(Header->zelda_version < 0x193)
13694 {
13695
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13696 {
13697 5 guysbuf[eDODONGO].cset=14;
13698 5 guysbuf[eDODONGO].bosspal=spDIG;
13699 5 }
13700 23 }
13701 // Not sure when this first changed, but it's necessary for 2.10, at least
13702 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13703 //2.10 Fixes
13704
3/6
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
469 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13705 {
13706 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13707 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13708 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13709 82 guysbuf[eCENT1].attributes[2] = 1;
13710 82 guysbuf[eCENT2].attributes[2] = 1;
13711 82 }
13712
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
469 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13713 {
13714 469 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13715 469 }
13716
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
469 if(Header->zelda_version <= 0x210)
13717 {
13718 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13719 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13720 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13721 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13722
13723 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13724 82 guysbuf[eBATROBE].attributes[3] = 1;
13725 //guysbuf[eSUMMONER].misc4 = 1;
13726 82 guysbuf[eWWIZ].attributes[3] = 1;
13727 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13728 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13729 82 }
13730
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 12 times.
469 if(Header->zelda_version == 0x190)
13731 {
13732 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13733 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13734 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13735 12 }
13736
13737 // The versions here may not be correct
13738 // zelda_version>=0x211 handled at guyversion<24
13739
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 451 times.
469 if(Header->zelda_version <= 0x190)
13740 {
13741 18 guysbuf[eCENT1].attributes[2] = 0;
13742 18 guysbuf[eCENT2].attributes[2] = 0;
13743 18 guysbuf[eMOLDORM].attributes[1] = 0;
13744 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13745 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13746 18 }
13747
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 64 times.
451 else if(Header->zelda_version <= 0x210)
13748 {
13749 64 guysbuf[eCENT1].attributes[2] = 1;
13750 64 guysbuf[eCENT2].attributes[2] = 1;
13751 64 guysbuf[eMOLDORM].attributes[1] = 0;
13752 64 }
13753
13754
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 82 times.
469 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13755 {
13756 82 guysbuf[eKEESE1].attributes[15] = 120;
13757 82 guysbuf[eKEESE2].attributes[15] = 120;
13758 82 guysbuf[eKEESE3].attributes[15] = 120;
13759 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13760 82 guysbuf[eKEESE1].attributes[16] = 16;
13761 82 guysbuf[eKEESE2].attributes[16] = 16;
13762 82 guysbuf[eKEESE3].attributes[16] = 16;
13763 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13764
13765 82 guysbuf[ePEAHAT].attributes[15] = 80;
13766 82 guysbuf[ePEAHAT].attributes[16] = 16;
13767
13768 82 guysbuf[eGHINI2].attributes[15] = 120;
13769 82 guysbuf[eGHINI2].attributes[16] = 10;
13770
13771
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13772 {
13773 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13774 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13775 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13776 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13777 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13778 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13779 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13780 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13781 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13782 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13783 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13784 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13785 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13786 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13787 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13788 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13789 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13790 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13791 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13792 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13793 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13794 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13795 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13796 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13797 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13798 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13799 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13800 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13801 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13802 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13803 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13804 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13805 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13806 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13807 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13808 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13809 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13810 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13811 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13812 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13813 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13814 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13815 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13816 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13817 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13818 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13819 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13820 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13821 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13822 66 }
13823 82 }
13824
13825
13826
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 387 times.
469 if(guyversion<=2)
13827 {
13828 82 return readherosprites2(f, guyversion==2?0:-1);
13829 }
13830
13831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(guyversion > 3)
13832 {
13833 guydata tempguy;
13834
13835
2/2
✓ Branch 0 taken 198144 times.
✓ Branch 1 taken 387 times.
198531 for(int32_t i=0; i<MAXGUYS; i++)
13836 {
13837
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 23) // May 2012 : 512 max enemies
13838 {
13839 if(i >= OLDBETAMAXGUYS)
13840 {
13841 memset(&guysbuf[i], 0, sizeof(guydata));
13842 continue;
13843 }
13844 }
13845
13846 198144 memset(&tempguy, 0, sizeof(guydata));
13847
13848 uint32_t flags1;
13849 uint32_t flags2;
13850
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetl(&(flags1),f))
13851 {
13852 return qe_invalid;
13853 }
13854
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetl(&(flags2),f))
13855 {
13856 return qe_invalid;
13857 }
13858 198144 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13859
13860
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion >= 36 ) //expanded tiles
13861 {
13862
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.tile),f))
13863 {
13864 return qe_invalid;
13865 }
13866 93184 }
13867 else
13868 {
13869
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.tile),f))
13870 {
13871 return qe_invalid;
13872 }
13873 }
13874
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.width),f))
13875 {
13876 return qe_invalid;
13877 }
13878
13879
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.height),f))
13880 {
13881 return qe_invalid;
13882 }
13883
13884
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion >= 36 ) //expanded tiles
13885 {
13886
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.s_tile),f))
13887 {
13888 return qe_invalid;
13889 }
13890 93184 }
13891 else
13892 {
13893
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.s_tile),f))
13894 {
13895 return qe_invalid;
13896 }
13897 }
13898
13899
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.s_width),f))
13900 {
13901 return qe_invalid;
13902 }
13903
13904
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.s_height),f))
13905 {
13906 return qe_invalid;
13907 }
13908
13909
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion >= 36 ) //expanded tiles
13910 {
13911
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.e_tile),f))
13912 {
13913 return qe_invalid;
13914 }
13915 93184 }
13916 else
13917 {
13918
1/2
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
104960 if(!p_igetw(&(tempguy.e_tile),f))
13919 {
13920 return qe_invalid;
13921 }
13922 }
13923
13924
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.e_width),f))
13925 {
13926 return qe_invalid;
13927 }
13928
13929
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.e_height),f))
13930 {
13931 return qe_invalid;
13932 }
13933
13934
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.hp),f))
13935 {
13936 return qe_invalid;
13937 }
13938
13939
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.family),f))
13940 {
13941 return qe_invalid;
13942 }
13943
13944
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
198144 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13945 {
13946 if(get_qr(qr_NEWENEMYTILES))
13947 {
13948 tempguy.s_tile=tempguy.e_tile+120;
13949 tempguy.s_width=tempguy.e_width;
13950 tempguy.s_height=tempguy.e_height;
13951 }
13952 else tempguy.s_tile=860;
13953 }
13954
13955
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.cset),f))
13956 {
13957 return qe_invalid;
13958 }
13959
13960
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.anim),f))
13961 {
13962 return qe_invalid;
13963 }
13964
13965
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.e_anim),f))
13966 {
13967 return qe_invalid;
13968 }
13969
13970
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.frate),f))
13971 {
13972 return qe_invalid;
13973 }
13974
13975
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.e_frate),f))
13976 {
13977 return qe_invalid;
13978 }
13979
13980
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 13) // April 2009
13981 {
13982 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13983 {
13984 tempguy.frate *= 2;
13985 tempguy.e_frate *= 2;
13986 }
13987 }
13988
13989
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 14) // May 1 2009
13990 {
13991 if(tempguy.anim==a2FRMSLOW)
13992 {
13993 tempguy.anim=a2FRM;
13994 tempguy.frate *= 2;
13995 }
13996
13997 if(tempguy.e_anim==a2FRMSLOW)
13998 {
13999 tempguy.e_anim=a2FRM;
14000 tempguy.e_frate *= 2;
14001 }
14002
14003 if(tempguy.anim==aFLIPSLOW)
14004 {
14005 tempguy.anim=aFLIP;
14006 tempguy.frate *= 2;
14007 }
14008
14009 if(tempguy.e_anim==aFLIPSLOW)
14010 {
14011 tempguy.e_anim=aFLIP;
14012 tempguy.e_frate *= 2;
14013 }
14014
14015 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14016
14017 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14018
14019 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14020 {
14021 tempguy.anim=a4FRM4DIR;
14022 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14023 }
14024
14025 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14026 {
14027 tempguy.e_anim=a4FRM4DIR;
14028 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14029 }
14030 }
14031
14032
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.dp),f))
14033 {
14034 return qe_invalid;
14035 }
14036
14037 //correction for guy fire
14038
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 6)
14039 {
14040 if(i == gFIRE)
14041 tempguy.dp = 2;
14042 }
14043
14044
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.wdp),f))
14045 {
14046 return qe_invalid;
14047 }
14048
14049
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.weapon),f))
14050 {
14051 return qe_invalid;
14052 }
14053
14054 //correction for bosses using triple, "rising" fireballs
14055
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 5)
14056 {
14057 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14058 i == eGOHMA3 || i == eGOHMA4)
14059 {
14060 if(tempguy.weapon == ewFireball)
14061 tempguy.weapon = ewFireball2;
14062 }
14063 }
14064
14065
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.rate),f))
14066 {
14067 return qe_invalid;
14068 }
14069
14070
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.hrate),f))
14071 {
14072 return qe_invalid;
14073 }
14074
14075
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.step),f))
14076 {
14077 return qe_invalid;
14078 }
14079
14080 // HIGHLY UNORTHODOX UPDATING THING, part 2
14081
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198144 if(fixpolsvoice && tempguy.family==eePOLSV)
14082 {
14083 tempguy.step /= 2;
14084 }
14085
14086
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.homing),f))
14087 {
14088 return qe_invalid;
14089 }
14090
14091
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.grumble),f))
14092 {
14093 return qe_invalid;
14094 }
14095
14096
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.item_set),f))
14097 {
14098 return qe_invalid;
14099 }
14100
14101
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14102 {
14103
2/2
✓ Branch 0 taken 1981440 times.
✓ Branch 1 taken 198144 times.
2179584 for (int q = 0; q < 10; ++q)
14104 {
14105
1/2
✓ Branch 0 taken 1981440 times.
✗ Branch 1 not taken.
1981440 if (!p_igetl(&(tempguy.attributes[q]), f))
14106 {
14107 return qe_invalid;
14108 }
14109 1981440 }
14110 198144 }
14111 else
14112 {
14113 int16_t tempMisc;
14114
14115 for(int q=0;q<10;q++)
14116 {
14117 if (!p_igetw(&tempMisc, f))
14118 {
14119 return qe_invalid;
14120 }
14121 tempguy.attributes[q] = tempMisc;
14122 }
14123
14124 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14125 {
14126 if(tempguy.family == eeWIZZ && !(tempguy.attributes[0]))
14127 tempguy.attributes[4] = 74;
14128 }
14129
14130 }
14131
14132
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.bgsfx),f))
14133 {
14134 return qe_invalid;
14135 }
14136
14137
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.bosspal),f))
14138 {
14139 return qe_invalid;
14140 }
14141
14142
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetw(&(tempguy.extend),f))
14143 {
14144 return qe_invalid;
14145 }
14146
14147 //! Enemy Defences
14148
14149 //If a 2.50 quest, use only the 2.5 defences.
14150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
198144 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14151 {
14152
2/2
✓ Branch 0 taken 3764736 times.
✓ Branch 1 taken 198144 times.
3962880 for(int32_t j=0; j<edefLAST; j++)
14153 {
14154
1/2
✓ Branch 0 taken 3764736 times.
✗ Branch 1 not taken.
3764736 if(!p_getc(&(tempguy.defense[j]),f))
14155 {
14156 return qe_invalid;
14157 }
14158 3764736 }
14159 //then copy the generic script defence to all the new script defences
14160
14161 198144 }
14162
14163
14164
14165
14166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198144 times.
198144 if(guyversion >= 18)
14167 {
14168
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.hitsfx),f))
14169 {
14170 return qe_invalid;
14171 }
14172
14173
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_getc(&(tempguy.deadsfx),f))
14174 {
14175 return qe_invalid;
14176 }
14177 198144 }
14178
14179
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion >= 22)
14180 {
14181
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetl(&(tempguy.attributes[10]), f))
14182 {
14183 return qe_invalid;
14184 }
14185
14186
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(!p_igetl(&(tempguy.attributes[11]),f))
14187 {
14188 return qe_invalid;
14189 }
14190 198144 }
14191 else if(guyversion >= 19)
14192 {
14193 int16_t tempMisc;
14194
14195 if(!p_igetw(&tempMisc,f))
14196 {
14197 return qe_invalid;
14198 }
14199
14200 tempguy.attributes[10] = tempMisc;
14201
14202 if(!p_igetw(&tempMisc,f))
14203 {
14204 return qe_invalid;
14205 }
14206
14207 tempguy.attributes[11] = tempMisc;
14208 }
14209
14210 //If a 2.54 or later quest, use all of the defences.
14211
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 24) // Add new guyversion conditional statement
14212 {
14213
2/2
✓ Branch 0 taken 2050048 times.
✓ Branch 1 taken 93184 times.
2143232 for(int32_t j=edefLAST; j<edefLAST255; j++)
14214 {
14215
1/2
✓ Branch 0 taken 2050048 times.
✗ Branch 1 not taken.
2050048 if(!p_getc(&(tempguy.defense[j]),f))
14216 {
14217 return qe_invalid;
14218 }
14219 2050048 }
14220 93184 }
14221
14222
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14223 {
14224
2/2
✓ Branch 0 taken 1049600 times.
✓ Branch 1 taken 104960 times.
1154560 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14225 {
14226 1049600 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14227 1049600 }
14228 104960 }
14229
14230 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14231
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 25)
14232 {
14233
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.txsz),f))
14234 {
14235 return qe_invalid;
14236 }
14237
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.tysz),f))
14238 {
14239 return qe_invalid;
14240 }
14241
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hxsz),f))
14242 {
14243 return qe_invalid;
14244 }
14245
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hysz),f))
14246 {
14247 return qe_invalid;
14248 }
14249
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hzsz),f))
14250 {
14251 return qe_invalid;
14252 }
14253 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14254
14255 */
14256 93184 }
14257 //More Enemy Editor vars for 2.60
14258
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 26)
14259 {
14260
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hxofs),f))
14261 {
14262 return qe_invalid;
14263 }
14264
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.hyofs),f))
14265 {
14266 return qe_invalid;
14267 }
14268
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.xofs),f))
14269 {
14270 return qe_invalid;
14271 }
14272
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.yofs),f))
14273 {
14274 return qe_invalid;
14275 }
14276
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.zofs),f))
14277 {
14278 return qe_invalid;
14279 }
14280 93184 }
14281
14282
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14283 {
14284 104960 tempguy.wpnsprite = 0;
14285 104960 }
14286
14287
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 27)
14288 {
14289
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.wpnsprite),f))
14290 {
14291 return qe_invalid;
14292 }
14293 93184 }
14294
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14295 {
14296 104960 tempguy.SIZEflags = 0;
14297 104960 }
14298
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion > 28)
14299 {
14300
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.SIZEflags),f))
14301 {
14302 return qe_invalid;
14303 }
14304
14305 93184 }
14306
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14307 {
14308 104960 tempguy.frozentile = 0;
14309 104960 tempguy.frozencset = 0;
14310 104960 tempguy.frozenclock = 0;
14311
2/2
✓ Branch 0 taken 1049600 times.
✓ Branch 1 taken 104960 times.
1154560 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14312 104960 }
14313
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion >= 30)
14314 {
14315
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.frozentile),f))
14316 {
14317 return qe_invalid;
14318 }
14319
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.frozencset),f))
14320 {
14321 return qe_invalid;
14322 }
14323
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.frozenclock),f))
14324 {
14325 return qe_invalid;
14326 }
14327
2/2
✓ Branch 0 taken 931840 times.
✓ Branch 1 taken 93184 times.
1025024 for ( int32_t q = 0; q < 10; q++ ) {
14328
1/2
✓ Branch 0 taken 931840 times.
✗ Branch 1 not taken.
931840 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14329 {
14330 return qe_invalid;
14331 }
14332 931840 }
14333
14334 93184 }
14335
14336
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion >= 34)
14337 {
14338
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetw(&(tempguy.firesfx),f))
14339 {
14340 return qe_invalid;
14341 }
14342
2/2
✓ Branch 0 taken 1584128 times.
✓ Branch 1 taken 93184 times.
1677312 for(int q=15;q<32;++q)
14343 {
14344
1/2
✓ Branch 0 taken 1584128 times.
✗ Branch 1 not taken.
1584128 if(!p_igetl(&(tempguy.attributes[q]),f))
14345 {
14346 return qe_invalid;
14347 }
14348 1584128 }
14349
14350
2/2
✓ Branch 0 taken 2981888 times.
✓ Branch 1 taken 93184 times.
3075072 for ( int32_t q = 0; q < 32; q++ ) {
14351
1/2
✓ Branch 0 taken 2981888 times.
✗ Branch 1 not taken.
2981888 if(!p_igetl(&(tempguy.movement[q]),f))
14352 {
14353 return qe_invalid;
14354 }
14355 2981888 }
14356
2/2
✓ Branch 0 taken 2981888 times.
✓ Branch 1 taken 93184 times.
3075072 for ( int32_t q = 0; q < 32; q++ ) {
14357
1/2
✓ Branch 0 taken 2981888 times.
✗ Branch 1 not taken.
2981888 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14358 {
14359 return qe_invalid;
14360 }
14361 2981888 }
14362
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetw(&(tempguy.script),f))
14363 {
14364 return qe_invalid;
14365 }
14366
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
14367 {
14368
1/2
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
745472 if(!p_igetl(&(tempguy.initD[q]),f))
14369 {
14370 return qe_invalid;
14371 }
14372 745472 }
14373
2/2
✓ Branch 0 taken 186368 times.
✓ Branch 1 taken 93184 times.
279552 for ( int32_t q = 0; q < 2; q++ )
14374 {
14375 int32_t temp;
14376
1/2
✓ Branch 0 taken 186368 times.
✗ Branch 1 not taken.
186368 if(!p_igetl(&temp,f))
14377 {
14378 return qe_invalid;
14379 }
14380 186368 }
14381
14382 93184 }
14383
14384
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion >= 37)
14385 {
14386
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.editorflags),f))
14387 {
14388 return qe_invalid;
14389 }
14390 93184 }
14391
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14392
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if(guyversion >= 38)
14393 {
14394
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.attributes[12]),f))
14395 {
14396 return qe_invalid;
14397 }
14398
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.attributes[13]),f))
14399 {
14400 return qe_invalid;
14401 }
14402
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetl(&(tempguy.attributes[14]),f))
14403 {
14404 return qe_invalid;
14405 }
14406
14407 93184 }
14408
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion < 38 )
14409 {
14410 104960 tempguy.attributes[12] = 0;
14411 104960 tempguy.attributes[13] = 0;
14412 104960 tempguy.attributes[14] = 0;
14413 104960 }
14414
14415
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if ( guyversion >= 39 )
14416 {
14417
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
14418 {
14419
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; w++ )
14420 {
14421
1/2
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
48455680 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14422 {
14423 return qe_invalid;
14424 }
14425 48455680 }
14426
2/2
✓ Branch 0 taken 48455680 times.
✓ Branch 1 taken 745472 times.
49201152 for ( int32_t w = 0; w < 65; w++ )
14427 {
14428
1/2
✓ Branch 0 taken 48455680 times.
✗ Branch 1 not taken.
48455680 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14429 {
14430 return qe_invalid;
14431 }
14432 48455680 }
14433 745472 }
14434
14435
14436 93184 }
14437
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion < 39 ) //apply old InitD strings to both
14438 {
14439
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for ( int32_t q = 0; q < 8; q++ )
14440 {
14441 839680 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14442 839680 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14443 839680 }
14444 104960 }
14445
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if ( guyversion >= 40 )
14446 {
14447
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_igetw(&(tempguy.weaponscript),f))
14448 {
14449 return qe_invalid;
14450 }
14451 93184 }
14452
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if ( guyversion < 40 )
14453 {
14454 104960 tempguy.weaponscript = 0;
14455 104960 }
14456 //eweapon script InitD
14457
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
198144 if ( guyversion >= 41 )
14458 {
14459
2/2
✓ Branch 0 taken 745472 times.
✓ Branch 1 taken 93184 times.
838656 for ( int32_t q = 0; q < 8; q++ )
14460 {
14461
1/2
✓ Branch 0 taken 745472 times.
✗ Branch 1 not taken.
745472 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14462 {
14463 return qe_invalid;
14464 }
14465 745472 }
14466
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if ( guy_cversion < 4 )
14467 {
14468 if ( tempguy.family == eeKEESE )
14469 {
14470
14471 if ( !tempguy.attributes[0] )
14472 {
14473 tempguy.attributes[15] = 120;
14474 tempguy.attributes[16] = 16;
14475
14476 }
14477 }
14478 if ( tempguy.family == eePEAHAT )
14479 {
14480 tempguy.attributes[15] = 80;
14481 tempguy.attributes[16] = 16;
14482 }
14483
14484 if ( tempguy.family == eeGHINI )
14485 {
14486 tempguy.attributes[15] = 120;
14487 tempguy.attributes[16] = 10;
14488 }
14489
14490 }
14491 93184 }
14492
14493
14494
14495 //default weapon sprites (quest version < 2.54)
14496 //port over old defaults -Z
14497
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 32)
14498 {
14499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if ( tempguy.wpnsprite <= 0 )
14500 {
14501
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89121 times.
✓ Branch 4 taken 817 times.
✓ Branch 5 taken 708 times.
✓ Branch 6 taken 1938 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 2445 times.
✓ Branch 9 taken 211 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1849 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 332 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1540 times.
104960 switch(tempguy.weapon)
14502 {
14503 case wNone:
14504 89121 tempguy.wpnsprite = 0; break;
14505
14506 case wSword:
14507 case wBeam:
14508 case wBrang:
14509 case wBomb:
14510 case wSBomb:
14511 case wLitBomb:
14512 case wLitSBomb:
14513 case wArrow:
14514 case wFire:
14515 case wWhistle:
14516 case wBait:
14517 case wWand:
14518 case wMagic:
14519 case wCatching:
14520 case wWind:
14521 case wRefMagic:
14522 case wRefFireball:
14523 case wRefRock:
14524 case wHammer:
14525 case wHookshot:
14526 case wHSHandle:
14527 case wHSChain:
14528 case wSSparkle:
14529 case wFSparkle:
14530 case wSmack:
14531 case wPhantom:
14532 case wCByrna:
14533 case wRefBeam:
14534 case wStomp:
14535 case lwMax:
14536 case wScript1:
14537 case wScript2:
14538 case wScript3:
14539 case wScript4:
14540 case wScript5:
14541 case wScript6:
14542 case wScript7:
14543 case wScript8:
14544 case wScript9:
14545 case wScript10:
14546 case wIce:
14547 //Cannot use any of these weapons yet.
14548 tempguy.wpnsprite = -1;
14549 break;
14550
14551 case wEnemyWeapons:
14552 2911 case ewFireball: tempguy.wpnsprite = 17; break;
14553
14554 817 case ewArrow: tempguy.wpnsprite = 19; break;
14555 708 case ewBrang: tempguy.wpnsprite = 4; break;
14556 1938 case ewSword: tempguy.wpnsprite = 20; break;
14557 1316 case ewRock: tempguy.wpnsprite = 18; break;
14558 2445 case ewMagic: tempguy.wpnsprite = 21; break;
14559 211 case ewBomb: tempguy.wpnsprite = 78; break;
14560 78 case ewSBomb: tempguy.wpnsprite = 79; break;
14561 457 case ewLitBomb: tempguy.wpnsprite = 76; break;
14562 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14563 924 case ewFireTrail: tempguy.wpnsprite = 80; break;
14564 1849 case ewFlame: tempguy.wpnsprite = 35; break;
14565 234 case ewWind: tempguy.wpnsprite = 36; break;
14566 332 case ewFlame2: tempguy.wpnsprite = 81; break;
14567 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14568 case ewIce: tempguy.wpnsprite = 83; break;
14569 1540 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14570
14571
14572 default: break; //No assign.
14573 }
14574 104960 }
14575 104960 }
14576
14577 //default weapon fire sound (quest version < 2.54)
14578 //port over old defaults and zero new data. -Z
14579
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 34)
14580 {
14581
2/2
✓ Branch 0 taken 3358720 times.
✓ Branch 1 taken 104960 times.
3463680 for ( int32_t q = 0; q < 32; q++ )
14582 {
14583 3358720 tempguy.movement[q] = 0;
14584 3358720 tempguy.new_weapon[q] = 0;
14585
14586 3358720 }
14587
14588 //NPC Script attributes.
14589 104960 tempguy.script = 0; //No scripted enemies existed. -Z
14590
2/2
✓ Branch 0 taken 839680 times.
✓ Branch 1 taken 104960 times.
944640 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14591
14592
2/2
✓ Branch 0 taken 1784320 times.
✓ Branch 1 taken 104960 times.
1889280 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14593
14594 //old default sounds
14595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
104960 if ( tempguy.firesfx <= 0 )
14596 {
14597
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89121 times.
✓ Branch 4 taken 817 times.
✓ Branch 5 taken 708 times.
✓ Branch 6 taken 1938 times.
✓ Branch 7 taken 1316 times.
✓ Branch 8 taken 2445 times.
✓ Branch 9 taken 211 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1849 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 332 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1540 times.
104960 switch(tempguy.weapon)
14598 {
14599 case wNone:
14600 89121 tempguy.firesfx = 0; break;
14601
14602 case wSword:
14603 case wBeam:
14604 case wBrang:
14605 case wBomb:
14606 case wSBomb:
14607 case wLitBomb:
14608 case wLitSBomb:
14609 case wArrow:
14610 case wFire:
14611 case wWhistle:
14612 case wBait:
14613 case wWand:
14614 case wMagic:
14615 case wCatching:
14616 case wWind:
14617 case wRefMagic:
14618 case wRefFireball:
14619 case wRefRock:
14620 case wHammer:
14621 case wHookshot:
14622 case wHSHandle:
14623 case wHSChain:
14624 case wSSparkle:
14625 case wFSparkle:
14626 case wSmack:
14627 case wPhantom:
14628 case wCByrna:
14629 case wRefBeam:
14630 case wStomp:
14631 case lwMax:
14632 case wScript1:
14633 case wScript2:
14634 case wScript3:
14635 case wScript4:
14636 case wScript5:
14637 case wScript6:
14638 case wScript7:
14639 case wScript8:
14640 case wScript9:
14641 case wScript10:
14642 case wIce:
14643 //Cannot use any of these weapons yet.
14644 tempguy.firesfx = -1;
14645 break;
14646
14647 case wEnemyWeapons:
14648 2911 case ewFireball: tempguy.firesfx = 40; break;
14649
14650 817 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14651 708 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14652 1938 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14653 1316 case ewRock: tempguy.firesfx = 51; break;
14654 2445 case ewMagic: tempguy.firesfx = 32; break;
14655 211 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14656 78 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14657 457 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14658 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14659 924 case ewFireTrail: tempguy.firesfx = 13; break;
14660 1849 case ewFlame: tempguy.firesfx = 13; break;
14661 234 case ewWind: tempguy.firesfx = 32; break;
14662 332 case ewFlame2: tempguy.firesfx = 13; break;
14663 case ewFlame2Trail: tempguy.firesfx = 13; break;
14664 case ewIce: tempguy.firesfx = 44; break;
14665 1540 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14666
14667 //what about special attacks (e.g. summoning == 56)
14668 default: break; //No assign.
14669 }
14670 104960 }
14671 104960 }
14672
14673 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14674
4/6
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 93184 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 93184 times.
198144 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14675 {
14676
2/2
✓ Branch 0 taken 14184 times.
✓ Branch 1 taken 90776 times.
104960 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14677 104960 }
14678 //Keese and bat halt rates.
14679
3/4
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 93184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104960 times.
198144 if ( guyversion < 42 && guy_cversion < 4 )
14680 {
14681
14682
2/2
✓ Branch 0 taken 103636 times.
✓ Branch 1 taken 1324 times.
104960 if ( tempguy.family == eeKEESE )
14683 {
14684
14685
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 955 times.
1324 if ( !tempguy.attributes[0] )
14686 {
14687 955 tempguy.attributes[15] = 120;
14688 955 tempguy.attributes[16] = 16;
14689
14690 955 }
14691 1324 }
14692
2/2
✓ Branch 0 taken 104486 times.
✓ Branch 1 taken 474 times.
104960 if ( tempguy.family == eePEAHAT )
14693 {
14694 474 tempguy.attributes[15] = 80;
14695 474 tempguy.attributes[16] = 16;
14696 474 }
14697
2/2
✓ Branch 0 taken 104755 times.
✓ Branch 1 taken 205 times.
104960 if ( tempguy.family == eeGHINI )
14698 {
14699 205 tempguy.attributes[15] = 120;
14700 205 tempguy.attributes[16] = 10;
14701 205 }
14702
14703
14704 104960 }
14705
14706
14707 //miscellaneous other corrections
14708 //fix the mirror wizzrobe -DD
14709
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 7)
14710 {
14711 if(i == eMWIZ)
14712 {
14713 tempguy.attributes[1] = 0;
14714 tempguy.attributes[3] = 1;
14715 }
14716 }
14717
14718
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 8)
14719 {
14720 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14721 {
14722 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14723 tempguy.attributes[4] = 4; //neck length in segments
14724 tempguy.attributes[5] = 8; //neck offset from first body tile
14725 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14726 tempguy.attributes[7] = 168; //head offset from first body tile
14727 tempguy.attributes[8] = 228; //flying head offset from first body tile
14728
14729 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14730 {
14731 tempguy.attributes[5] += 10; //neck offset from first body tile
14732 tempguy.attributes[7] -= 12; //head offset from first body tile
14733 }
14734 }
14735 }
14736
14737
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14738 {
14739 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.attributes[0]==0)
14740 tempguy.bosspal = spDIG;
14741 }
14742
14743
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 11) // December 2007 - Spinning Tile fix
14744 {
14745 if(tempguy.family==eeSPINTILE)
14746 {
14747 tempguy.flags |= guy_superman;
14748 tempguy.item_set = 0; // Don't drop items
14749 tempguy.step = 300;
14750 }
14751 }
14752
14753
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14754 {
14755 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14756 {
14757 if(tempguy.family==eeROPE)
14758 {
14759 tempguy.flags &= ~guy_flashing;
14760 }
14761 }
14762
14763 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14764 {
14765 if(tempguy.family==eeBUBBLE)
14766 {
14767 tempguy.flags &= ~guy_flashing;
14768 }
14769 }
14770
14771 if((tempguy.family==eeGHINI)&&(tempguy.attributes[0]))
14772 {
14773 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14774 {
14775 tempguy.flags |= guy_blinking;
14776 }
14777
14778 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14779 {
14780 tempguy.flags |= guy_transparent;
14781 }
14782 }
14783 }
14784
14785
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14786 {
14787 if(i==gFIRE)
14788 {
14789 tempguy.e_anim = aFLIP;
14790 tempguy.e_frate = 24;
14791 }
14792
14793 if(i==gFAIRY)
14794 {
14795 tempguy.e_anim = a2FRM;
14796 tempguy.e_frate = 16;
14797 }
14798 }
14799
14800
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14801 {
14802 if(i==0) Z_message("Updating guys to version 16...\n");
14803
14804 update_guy_1(&tempguy);
14805
14806 if(i==eMPOLSV)
14807 {
14808 tempguy.defense[edefARROW] = edCHINK;
14809 tempguy.defense[edefMAGIC] = ed1HKO;
14810 tempguy.defense[edefREFMAGIC] = ed1HKO;
14811 }
14812 }
14813
14814
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 17) // December 2009
14815 {
14816 if(tempguy.family==eePROJECTILE)
14817 {
14818 tempguy.attributes[0] = 0;
14819 }
14820 }
14821
14822
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 18) // January 2010
14823 {
14824 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14825 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14826
14827 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14828 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14829
14830 if(tempguy.family == eeAQUA)
14831 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14832 else if(tempguy.family == eeMANHAN)
14833 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14834 else if(tempguy.family==eePATRA)
14835 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14836 else if(tempguy.family==eeGHOMA)
14837 {
14838 for(int32_t j=0; j<edefLAST; j++)
14839 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14840
14841 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14842
14843 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14844
14845 tempguy.attributes[0]--;
14846 }
14847 else if(tempguy.family == eeGLEEOK)
14848 {
14849 for(int32_t j=0; j<edefLAST; j++)
14850 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14851
14852 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14853 }
14854 else if(tempguy.family == eeARMOS)
14855 {
14856 tempguy.family=eeWALK;
14857 tempguy.hrate = 0;
14858 tempguy.attributes[9] = tempguy.attributes[0];
14859 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14860 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14861 tempguy.attributes[8] = e9tARMOS;
14862 }
14863 else if(tempguy.family == eeGHINI && !tempguy.attributes[0])
14864 {
14865 tempguy.family=eeWALK;
14866 tempguy.hrate = 0;
14867 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14868 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14869 }
14870
14871 // Spawn animation flags
14872 if(tempguy.family == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14873 tempguy.flags |= guy_fade_flicker;
14874 else
14875 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14876 }
14877
14878
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 20) // April 2010
14879 {
14880 if(tempguy.family == eeTRAP)
14881 {
14882 tempguy.attributes[1] = tempguy.attributes[9];
14883
14884 if(tempguy.attributes[9]>=1)
14885 {
14886 tempguy.attributes[0]++;
14887 }
14888
14889 tempguy.attributes[9] = 0;
14890 }
14891
14892 // Bomb Blast fix
14893 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14894 tempguy.weapon = ewLitBomb;
14895 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14896 tempguy.weapon = ewLitSBomb;
14897 }
14898
14899
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 21) // September 2011
14900 {
14901 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14902 {
14903 if(tempguy.family == eeKEESETRIB)
14904 {
14905 tempguy.family = eeKEESE;
14906 tempguy.attributes[1] = e2tKEESETRIB;
14907 tempguy.attributes[0] = 0;
14908 }
14909
14910 tempguy.rate = 2;
14911 tempguy.hrate = 8;
14912 tempguy.homing = 0;
14913 tempguy.step= (tempguy.family == eeKEESE && tempguy.attributes[0] ? 100:62);
14914 }
14915 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14916 {
14917 if(tempguy.family == eePEAHAT)
14918 {
14919 tempguy.rate = 4;
14920 tempguy.step = 62;
14921 }
14922 else
14923 tempguy.step = 25;
14924
14925 tempguy.hrate = 8;
14926 tempguy.homing = 0;
14927 }
14928 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14929 {
14930 if(tempguy.family == eeMANHAN)
14931 tempguy.step=50;
14932
14933 tempguy.hrate = 16;
14934 tempguy.homing = 0;
14935 }
14936 else if(tempguy.family == eeGLEEOK)
14937 {
14938 tempguy.rate = 2;
14939 tempguy.homing = 0;
14940 tempguy.hrate = 9;
14941 tempguy.step=89;
14942 }
14943 else if(tempguy.family == eeGHINI)
14944 {
14945 tempguy.rate = 4;
14946 tempguy.hrate = 12;
14947 tempguy.step=62;
14948 tempguy.homing = 0;
14949 }
14950
14951 // Bigdig random rate fix
14952 if(tempguy.family==eeDIG && tempguy.attributes[9]==1)
14953 {
14954 tempguy.rate = 2;
14955 }
14956 }
14957
14958
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(guyversion < 24) // November 2012
14959 {
14960 if(tempguy.family==eeLANM)
14961 tempguy.attributes[2] = 1;
14962 else if(tempguy.family==eeMOLD)
14963 tempguy.attributes[1] = 0;
14964 }
14965
14966
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14967 {
14968
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
104960 if(tempguy.family!=eeDIG)
14969 {
14970 103530 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14971 103530 }
14972
14973 104960 }
14974 // does not seem to solve the issue!
14975
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if ( Header->zelda_version <= 0x210 )
14976 {
14977 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14978 if ( tempguy.family == eeDONGO )
14979 {
14980 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14981 }
14982 }
14983
14984
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion >= 42)
14985 {
14986
2/2
✓ Branch 0 taken 90624 times.
✓ Branch 1 taken 2560 times.
93184 if(guyversion >= 47)
14987 {
14988
1/2
✓ Branch 0 taken 90624 times.
✗ Branch 1 not taken.
90624 if(!p_igetl(&(tempguy.moveflags),f))
14989 {
14990 return qe_invalid;
14991 }
14992 90624 }
14993 else
14994 {
14995 byte fl;
14996
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14997 {
14998 return qe_invalid;
14999 }
15000 2560 tempguy.moveflags = (move_flags)fl;
15001 }
15002 93184 }
15003 else
15004 {
15005
7/8
✓ Branch 0 taken 3146 times.
✓ Branch 1 taken 82805 times.
✓ Branch 2 taken 2767 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 970 times.
✓ Branch 5 taken 655 times.
✓ Branch 6 taken 508 times.
✓ Branch 7 taken 14109 times.
104960 switch(tempguy.family)
15006 {
15007 //No gravity; floats over pits
15008 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15009 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15010 //Special (bosses, etc)
15011 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15012 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15013 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15014 82805 tempguy.moveflags = move_can_pitwalk;
15015 82805 break;
15016 //No gravity, but falls in pits
15017 case eeLEV:
15018 970 tempguy.moveflags = move_can_pitfall;
15019 970 break;
15020 //Bosses that respect pits
15021 case eeDONGO:
15022 655 tempguy.moveflags = move_obeys_grav;
15023 655 break;
15024 case eeLANM:
15025 508 tempguy.moveflags = move_none;
15026 508 break;
15027 //Gravity, floats over pits
15028 case eeWIZZ: case eeWALLM: case eeGHINI:
15029 2767 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15030 2767 break;
15031 //Gravity and falls in pits
15032 case eeWALK:
15033
4/4
✓ Branch 0 taken 13399 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 538 times.
✓ Branch 3 taken 12861 times.
14109 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15034 1248 break;
15035 [[fallthrough]];
15036 case eeOTHER:
15037 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15038 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15039 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15040 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15041 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15042 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15043 16007 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15044 16007 }
15045 }
15046
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 43)
15047 {
15048
2/2
✓ Branch 0 taken 85572 times.
✓ Branch 1 taken 19388 times.
104960 switch(tempguy.family)
15049 {
15050 //No gravity; floats over pits
15051 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15052 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15053 //Special (bosses, etc)
15054 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15055 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15056 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15057 case eeWIZZ: case eeWALLM: case eeGHINI:
15058 //Gravity, floats over pits
15059 85572 tempguy.moveflags |= move_can_waterwalk;
15060 85572 tempguy.moveflags |= move_can_pitwalk;
15061 85572 break;
15062 }
15063 104960 }
15064
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if (guyversion < 44)
15065 {
15066
2/2
✓ Branch 0 taken 104028 times.
✓ Branch 1 taken 932 times.
104960 if ( tempguy.family == eeGHOMA )
15067 {
15068 932 tempguy.flags |= guy_fade_instant;
15069 932 }
15070 104960 }
15071
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if (guyversion > 44)
15072 {
15073
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&(tempguy.spr_shadow),f))
15074 {
15075 return qe_invalid;
15076 }
15077
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&(tempguy.spr_death),f))
15078 {
15079 return qe_invalid;
15080 }
15081
1/2
✓ Branch 0 taken 93184 times.
✗ Branch 1 not taken.
93184 if(!p_getc(&(tempguy.spr_spawn),f))
15082 {
15083 return qe_invalid;
15084 }
15085 93184 }
15086 else
15087 {
15088
2/2
✓ Branch 0 taken 104553 times.
✓ Branch 1 taken 407 times.
104960 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15089 104960 tempguy.spr_death = iwDeath;
15090 104960 tempguy.spr_spawn = iwSpawn;
15091 }
15092
15093
2/2
✓ Branch 0 taken 93184 times.
✓ Branch 1 taken 104960 times.
198144 if(guyversion < 46)
15094 {
15095
4/4
✓ Branch 0 taken 14109 times.
✓ Branch 1 taken 90851 times.
✓ Branch 2 taken 13399 times.
✓ Branch 3 taken 710 times.
104960 if(tempguy.family == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15096 {
15097 710 tempguy.moveflags |= move_can_waterwalk;
15098 710 }
15099 104960 }
15100
15101
2/2
✓ Branch 0 taken 90624 times.
✓ Branch 1 taken 107520 times.
198144 if (guyversion < 47)
15102 {
15103
4/4
✓ Branch 0 taken 1460 times.
✓ Branch 1 taken 106060 times.
✓ Branch 2 taken 876 times.
✓ Branch 3 taken 584 times.
107520 if (tempguy.family == eeDIG && tempguy.attributes[9]!=1)
15104 {
15105 584 tempguy.flags |= guy_ignore_kill_all;
15106 584 }
15107 107520 }
15108
15109
2/2
✓ Branch 0 taken 70144 times.
✓ Branch 1 taken 128000 times.
198144 if (guyversion < 49)
15110 {
15111
8/8
✓ Branch 0 taken 16638 times.
✓ Branch 1 taken 111362 times.
✓ Branch 2 taken 16157 times.
✓ Branch 3 taken 481 times.
✓ Branch 4 taken 15665 times.
✓ Branch 5 taken 492 times.
✓ Branch 6 taken 537 times.
✓ Branch 7 taken 15128 times.
128000 if (tempguy.family == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15112 {
15113
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 727 times.
✓ Branch 3 taken 61 times.
1510 switch (tempguy.attributes[7]) {
15114 case 0: //Sword
15115 722 tempguy.attributes[7] = e8tSWORD;
15116 722 break;
15117 case 1: //Item
15118 727 tempguy.attributes[7] = e8tITEM;
15119 727 break;
15120 case 2: //Both
15121 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15122 61 break;
15123 default: //this can actually happen since Misc8 can be set to any number.
15124 tempguy.attributes[7] = 0;
15125 break;
15126 }
15127 1510 }
15128 128000 }
15129
15130 //these could possible be combined but rather be safe...
15131
2/2
✓ Branch 0 taken 70144 times.
✓ Branch 1 taken 128000 times.
198144 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15132 {
15133 128000 guy_update_firesfx(tempguy);
15134 128000 }
15135
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 70144 times.
198144 if (guyversion < 52)
15136 {
15137 128000 guy_update_weaponflags(tempguy);
15138 128000 }
15139 else
15140 {
15141
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_getc(&(tempguy.wunblockable), f))
15142 return qe_invalid;
15143
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.wmoveflags), f))
15144 return qe_invalid;
15145
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weapoverrideFLAGS), f))
15146 return qe_invalid;
15147
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_tilew), f))
15148 return qe_invalid;
15149
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_tileh), f))
15150 return qe_invalid;
15151
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hxsz), f))
15152 return qe_invalid;
15153
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hysz), f))
15154 return qe_invalid;
15155
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hzsz), f))
15156 return qe_invalid;
15157
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hxofs), f))
15158 return qe_invalid;
15159
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_hyofs), f))
15160 return qe_invalid;
15161
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_xofs), f))
15162 return qe_invalid;
15163
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.weap_yofs), f))
15164 return qe_invalid;
15165
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_igetl(&(tempguy.wstep), f))
15166 return qe_invalid;
15167
2/2
✓ Branch 0 taken 350720 times.
✓ Branch 1 taken 70144 times.
420864 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15168 {
15169
1/2
✓ Branch 0 taken 350720 times.
✗ Branch 1 not taken.
350720 if (!p_igetw(&(tempguy.burnsprs[q]), f))
15170 return qe_invalid;
15171
1/2
✓ Branch 0 taken 350720 times.
✗ Branch 1 not taken.
350720 if (!p_igetw(&(tempguy.light_rads[q]), f))
15172 return qe_invalid;
15173 350720 }
15174 }
15175
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 70144 times.
198144 if (guyversion < 53)
15176 {
15177 128000 guy_update_weaponspecialsfx(tempguy);
15178 128000 }
15179 else
15180 {
15181
1/2
✓ Branch 0 taken 70144 times.
✗ Branch 1 not taken.
70144 if (!p_getc(&(tempguy.specialsfx), f))
15182 return qe_invalid;
15183 }
15184
15185
1/2
✓ Branch 0 taken 198144 times.
✗ Branch 1 not taken.
198144 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15186 {
15187 tempguy.script = 0;
15188 for(int q = 0; q < 8; ++q)
15189 tempguy.initD[q] = 0;
15190 }
15191 198144 guysbuf[i] = tempguy;
15192 198144 }
15193 387 }
15194
15195 387 return 0;
15196 469 }
15197
15198 void update_guy_1(guydata *tempguy) // November 2009
15199 {
15200 bool doesntcount = false;
15201 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15202
15203 switch(tempguy->family)
15204 {
15205 case 1: //eeWALK
15206 switch(tempguy->attributes[9])
15207 {
15208 case 0: //Stalfos
15209 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15210 tempguy->attributes[0]=4;
15211
15212 break;
15213
15214 case 1: //Darknut
15215 goto darknuts;
15216 break;
15217 }
15218
15219 tempguy->attributes[9] = 0;
15220 break;
15221
15222 case 2: //eeSHOOT
15223 tempguy->family = eeWALK;
15224
15225 switch(tempguy->attributes[9])
15226 {
15227 case 0: //Octorok
15228 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15229 {
15230 tempguy->attributes[0]=e1tFIREOCTO;
15231 tempguy->attributes[1]=e2tFIREOCTO;
15232 }
15233 else tempguy->attributes[0] = 0;
15234
15235 tempguy->attributes[5]=tempguy->attributes[3];
15236 tempguy->attributes[3]=tempguy->attributes[2];
15237 tempguy->attributes[2]=0;
15238 break;
15239
15240 case 1: // Moblin
15241 tempguy->attributes[0] = 0;
15242 break;
15243
15244 case 2: //Lynel
15245 tempguy->attributes[5]=tempguy->attributes[0]+1;
15246 tempguy->attributes[0]=0;
15247 break;
15248
15249 case 3: //Stalfos 2
15250 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15251 tempguy->attributes[0]=e1t4SHOTS;
15252 else tempguy->attributes[0] = 0;
15253
15254 break;
15255
15256 case 4: //Darknut 5
15257 darknuts:
15258 tempguy->defense[edefFIRE] = edIGNORE;
15259 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15260 tempguy->defense[edefHOOKSHOT] = 0;
15261 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15262 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15263
15264 if(tempguy->attributes[0]==1)
15265 tempguy->attributes[0]=2;
15266 else if(tempguy->attributes[0]==2)
15267 {
15268 tempguy->attributes[3]=tempguy->attributes[2];
15269 tempguy->attributes[2]=tempguy->attributes[1];
15270 tempguy->attributes[1]=e2tSPLIT;
15271 tempguy->attributes[0] = 0;
15272 }
15273 else tempguy->attributes[0] = 0;
15274
15275 tempguy->flags |= guy_shield_front;
15276
15277 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15278 tempguy->flags &= ~guy_bkshield;
15279 else
15280 tempguy->flags |= guy_bkshield;
15281
15282 break;
15283 }
15284
15285 tempguy->attributes[9] = 0;
15286 break;
15287
15288 /*
15289 case 9: //eeARMOS
15290 tempguy->family = eeWALK;
15291 break;
15292 */
15293 case 11: //eeGEL
15294 case 33: //eeGELTRIB
15295 if(tempguy->family==33)
15296 {
15297 tempguy->attributes[3] = 1;
15298
15299 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15300 tempguy->attributes[2] = tempguy->attributes[1];
15301
15302 tempguy->attributes[1] = e2tTRIBBLE;
15303 }
15304 else
15305 {
15306 tempguy->attributes[3] = 0;
15307 tempguy->attributes[2] = 0;
15308 tempguy->attributes[1] = 0;
15309 }
15310
15311 tempguy->family = eeWALK;
15312
15313 if(tempguy->attributes[0])
15314 {
15315 tempguy->attributes[0]=1;
15316 tempguy->weapon = ewFireTrail;
15317 }
15318
15319 break;
15320
15321 case 34: //eeZOLTRIB
15322 case 12: //eeZOL
15323 tempguy->attributes[3]=tempguy->attributes[2];
15324 tempguy->attributes[2]=tempguy->attributes[1];
15325 tempguy->family = eeWALK;
15326 tempguy->attributes[1]=e2tSPLITHIT;
15327
15328 if(tempguy->attributes[0])
15329 {
15330 tempguy->attributes[0]=1;
15331 tempguy->weapon = ewFireTrail;
15332 }
15333
15334 break;
15335
15336 case 13: //eeROPE
15337 tempguy->family = eeWALK;
15338 tempguy->attributes[8] = e9tROPE;
15339
15340 if(tempguy->attributes[0])
15341 {
15342 tempguy->attributes[3] = tempguy->attributes[2];
15343 tempguy->attributes[2] = tempguy->attributes[1];
15344 tempguy->attributes[1] = e2tBOMBCHU;
15345 }
15346
15347 tempguy->attributes[0] = 0;
15348 break;
15349
15350 case 14: //eeGORIYA
15351 tempguy->family = eeWALK;
15352
15353 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15354
15355 break;
15356
15357 case 17: //eeBUBBLE
15358 tempguy->family = eeWALK;
15359 tempguy->attributes[7] = tempguy->attributes[1];
15360 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15361 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15362
15363 //fallthrogh
15364 case eeTRAP:
15365 case eeROCK:
15366 doesntcount = true;
15367 break;
15368
15369 case 35: //eeVIRETRIB
15370 case 18: //eeVIRE
15371 tempguy->family = eeWALK;
15372 tempguy->attributes[3]=tempguy->attributes[2];
15373 tempguy->attributes[2]=tempguy->attributes[1];
15374 tempguy->attributes[1]=e2tSPLITHIT;
15375 tempguy->attributes[8]=e9tVIRE;
15376 break;
15377
15378 case 19: //eeLIKE
15379 tempguy->family = eeWALK;
15380 tempguy->attributes[6] = e7tEATITEMS;
15381 tempguy->attributes[7]=95;
15382 break;
15383
15384 case 20: //eePOLSV
15385 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15386 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15387 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15388 tempguy->defense[edefARROW] = ed1HKO;
15389 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15390 tempguy->family = eeWALK;
15391 tempguy->attributes[8] = e9tPOLSVOICE;
15392 tempguy->rate = 4;
15393 tempguy->homing = 32;
15394 tempguy->hrate = 10;
15395 tempguy->grumble = 0;
15396 break;
15397
15398 case eeWIZZ:
15399 if(tempguy->attributes[3])
15400 {
15401 for(int32_t i=0; i < edefLAST; i++)
15402 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15403 }
15404 else
15405 {
15406 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15407 tempguy->defense[edefMAGIC] = edCHINK;
15408 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15409 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15410 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15411 }
15412
15413 break;
15414
15415 case eePEAHAT:
15416 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15417
15418 if(!(tempguy->flags & guy_bhit))
15419 tempguy->defense[edefBRANG] = edSTUNONLY;
15420
15421 break;
15422
15423 case eeLEV:
15424 tempguy->defense[edefSTOMP] = edCHINK;
15425 break;
15426 }
15427
15428 // Old flags
15429 if(tempguy->flags & guy_superman)
15430 {
15431 for(int32_t i = 0; i < edefLAST; i++)
15432 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15433 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15434 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15435 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15436 }
15437
15438 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15439
15440 if(doesntcount)
15441 tempguy->flags |= (guy_doesnt_count);
15442 }
15443
15444 1186472 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15445 {
15446 byte tempbyte, padding;
15447 int32_t extras, secretcombos;
15448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->valid),f))
15449 {
15450 return qe_invalid;
15451 }
15452
15453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->guy),f))
15454 return qe_invalid;
15455 1186472 temp_mapscr->guytile = -1; //signal to use default guy values
15456
2/2
✓ Branch 0 taken 1185873 times.
✓ Branch 1 taken 599 times.
1186472 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15457
4/4
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 1185873 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 539 times.
1186472 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15458
15459
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15460 {
15461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15462 {
15463 return qe_invalid;
15464 }
15465
15466 22176 temp_mapscr->str=tempbyte;
15467 22176 }
15468 else
15469 {
15470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164296 times.
1164296 if(!p_igetw(&(temp_mapscr->str),f))
15471 {
15472 return qe_invalid;
15473 }
15474 }
15475
15476
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->room),f))
15477 {
15478 return qe_invalid;
15479 }
15480
15481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->item),f))
15482 {
15483 return qe_invalid;
15484 }
15485
15486
3/6
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 657968 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15487 {
15488 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15489 528504 }
15490 else
15491 {
15492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->hasitem),f))
15493 return qe_invalid;
15494 }
15495
15496
3/4
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1189192 if((Header->zelda_version < 0x192)||
15497
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
1164296 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15498 {
15499
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15500 {
15501 return qe_invalid;
15502 }
15503 22176 }
15504
15505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15506 {
15507 return qe_invalid;
15508 }
15509
15510
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15511 {
15512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15513 {
15514 return qe_invalid;
15515 }
15516 24896 }
15517
15518
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15519 {
15520
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15521 {
15522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15523 {
15524 return qe_invalid;
15525 }
15526 1973904 }
15527 657968 }
15528 else
15529 {
15530 528504 temp_mapscr->tilewarptype[1]=0;
15531 528504 temp_mapscr->tilewarptype[2]=0;
15532 528504 temp_mapscr->tilewarptype[3]=0;
15533 }
15534
15535
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15536 {
15537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164296 times.
1164296 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15538 {
15539 return qe_invalid;
15540 }
15541 1164296 }
15542
15543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15544 {
15545 return qe_invalid;
15546 }
15547
15548 1186472 temp_mapscr->warpreturnx[1]=0;
15549 1186472 temp_mapscr->warpreturnx[2]=0;
15550 1186472 temp_mapscr->warpreturnx[3]=0;
15551
15552
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15553 {
15554
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15555 {
15556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15557 {
15558 return qe_invalid;
15559 }
15560 1973904 }
15561 657968 }
15562
15563
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15564 {
15565 return qe_invalid;
15566 }
15567
15568 1186472 temp_mapscr->warpreturny[1]=0;
15569 1186472 temp_mapscr->warpreturny[2]=0;
15570 1186472 temp_mapscr->warpreturny[3]=0;
15571
15572
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15573 {
15574
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15575 {
15576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15577 {
15578 return qe_invalid;
15579 }
15580 1973904 }
15581
15582
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(version>=18)
15583 {
15584
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15585 {
15586 return qe_invalid;
15587 }
15588 657968 }
15589 else
15590 {
15591 byte temp;
15592
15593 if(!p_getc(&temp,f))
15594 {
15595 return qe_invalid;
15596 }
15597
15598 temp_mapscr->warpreturnc=temp<<8|temp;
15599 }
15600 657968 }
15601
15602
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->stairx),f))
15603
15604 {
15605 return qe_invalid;
15606 }
15607
15608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->stairy),f))
15609 {
15610 return qe_invalid;
15611 }
15612
15613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->itemx),f))
15614 {
15615 return qe_invalid;
15616 }
15617
15618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->itemy),f))
15619 {
15620 return qe_invalid;
15621 }
15622
15623
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version > 15) // February 2009
15624 {
15625
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->color),f))
15626 {
15627 return qe_invalid;
15628 }
15629 657968 }
15630 else
15631 {
15632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15633 {
15634 return qe_invalid;
15635 }
15636
15637 528504 temp_mapscr->color = (word) tempbyte;
15638 }
15639
15640
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->flags11),f))
15641 {
15642 return qe_invalid;
15643 }
15644
15645
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
15646 {
15647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4745888 times.
4745888 if(!p_getc(&(temp_mapscr->door[k]),f))
15648 {
15649 return qe_invalid;
15650
15651 }
15652 4745888 }
15653
15654
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version <= 11)
15655 {
15656
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15657 {
15658 return qe_invalid;
15659 }
15660
15661 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15662
15663
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15664 {
15665 for(int32_t i=1; i<4; i++)
15666 {
15667 if(!p_getc(&(tempbyte),f))
15668 {
15669 return qe_invalid;
15670 }
15671
15672 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15673 }
15674 }
15675 else
15676 {
15677 528504 temp_mapscr->tilewarpdmap[1]=0;
15678 528504 temp_mapscr->tilewarpdmap[2]=0;
15679 528504 temp_mapscr->tilewarpdmap[3]=0;
15680 }
15681 528504 }
15682 else
15683 {
15684
2/2
✓ Branch 0 taken 2631872 times.
✓ Branch 1 taken 657968 times.
3289840 for(int32_t i=0; i<4; i++)
15685 {
15686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2631872 times.
2631872 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15687 {
15688 return qe_invalid;
15689 }
15690 2631872 }
15691 }
15692
15693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15694 {
15695 return qe_invalid;
15696 }
15697
15698
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15699 {
15700
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15701 {
15702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15703 {
15704 return qe_invalid;
15705 }
15706 1973904 }
15707 657968 }
15708 else
15709 {
15710 528504 temp_mapscr->tilewarpscr[1]=0;
15711 528504 temp_mapscr->tilewarpscr[2]=0;
15712 528504 temp_mapscr->tilewarpscr[3]=0;
15713 }
15714
15715
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version >= 15)
15716 {
15717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15718 {
15719 return qe_invalid;
15720 }
15721 657968 }
15722 else
15723 {
15724 528504 temp_mapscr->tilewarpoverlayflags=0;
15725 }
15726
15727
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->exitdir),f))
15728 {
15729 return qe_invalid;
15730 }
15731
15732
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15733 {
15734
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15735 {
15736 return qe_invalid;
15737 }
15738
15739 24896 }
15740
15741
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15742 {
15743 if(!p_getc(&padding,f))
15744 {
15745 return qe_invalid;
15746 }
15747 }
15748
15749
2/2
✓ Branch 0 taken 11864720 times.
✓ Branch 1 taken 1186472 times.
13051192 for(int32_t k=0; k<10; k++)
15750 {
15751
5/6
✓ Branch 0 taken 11642960 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11615760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11864720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15752 {
15753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15754 {
15755 return qe_invalid;
15756 }
15757
15758 221760 temp_mapscr->enemy[k]=tempbyte;
15759 221760 }
15760 else
15761 {
15762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11642960 times.
11642960 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15763 {
15764 return qe_invalid;
15765 }
15766 }
15767
15768
5/6
✓ Branch 0 taken 11642960 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11615760 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11864720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15769 {
15770 //using enumerations here is dangerous
15771 //very easy to break old quests -DD
15772
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15773 {
15774 1342 temp_mapscr->enemy[k]+=5;
15775 1342 }
15776
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15777 {
15778 94 temp_mapscr->enemy[k]+=1;
15779 94 }
15780 221760 }
15781
15782
2/2
✓ Branch 0 taken 6579680 times.
✓ Branch 1 taken 5285040 times.
11864720 if(version < 9)
15783 {
15784
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15785 {
15786 275905 temp_mapscr->enemy[k]+=10;
15787 275905 }
15788 5285040 }
15789 //don't read in any invalid data
15790
2/2
✓ Branch 0 taken 11864270 times.
✓ Branch 1 taken 450 times.
11864720 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15791 {
15792 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15793 450 temp_mapscr->enemy[k] = 0;
15794 450 }
15795 11864720 }
15796
15797
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->pattern),f))
15798 {
15799 return qe_invalid;
15800 }
15801
15802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15803 {
15804 return qe_invalid;
15805 }
15806
15807
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15808 {
15809
2/2
✓ Branch 0 taken 1973904 times.
✓ Branch 1 taken 657968 times.
2631872 for(int32_t i=1; i<4; i++)
15810 {
15811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15812 {
15813 return qe_invalid;
15814 }
15815 1973904 }
15816 657968 }
15817 else
15818 {
15819 528504 temp_mapscr->sidewarptype[1]=0;
15820 528504 temp_mapscr->sidewarptype[2]=0;
15821 528504 temp_mapscr->sidewarptype[3]=0;
15822 }
15823
15824
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version >= 15)
15825 {
15826
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15827 {
15828 return qe_invalid;
15829 }
15830 657968 }
15831 else
15832 {
15833 528504 temp_mapscr->sidewarpoverlayflags=0;
15834 }
15835
15836
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15837 {
15838 return qe_invalid;
15839 }
15840
15841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15842 {
15843 return qe_invalid;
15844 }
15845
15846
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
15847 {
15848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4745888 times.
4745888 if(!p_getc(&(temp_mapscr->path[k]),f))
15849 {
15850 return qe_invalid;
15851 }
15852 4745888 }
15853
15854
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15855 {
15856 return qe_invalid;
15857 }
15858
15859
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15860 {
15861
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 1973904 times.
2631872 for(int32_t i=1; i<4; i++)
15862 {
15863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973904 times.
1973904 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15864 {
15865 return qe_invalid;
15866 }
15867 1973904 }
15868 657968 }
15869 else
15870 {
15871 528504 temp_mapscr->sidewarpscr[1]=0;
15872 528504 temp_mapscr->sidewarpscr[2]=0;
15873 528504 temp_mapscr->sidewarpscr[3]=0;
15874 }
15875
15876
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version <= 11)
15877 {
15878
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15879 {
15880 return qe_invalid;
15881 }
15882
15883 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15884
15885
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15886 {
15887 for(int32_t i=1; i<4; i++)
15888 {
15889 if(!p_getc(&(tempbyte),f))
15890 {
15891 return qe_invalid;
15892 }
15893
15894 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15895 }
15896 }
15897 else
15898 {
15899 528504 temp_mapscr->sidewarpdmap[1]=0;
15900 528504 temp_mapscr->sidewarpdmap[2]=0;
15901 528504 temp_mapscr->sidewarpdmap[3]=0;
15902 }
15903 528504 }
15904 else
15905 {
15906
2/2
✓ Branch 0 taken 2631872 times.
✓ Branch 1 taken 657968 times.
3289840 for(int32_t i=0; i<4; i++)
15907 {
15908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2631872 times.
2631872 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15909 {
15910 return qe_invalid;
15911 }
15912 2631872 }
15913 }
15914
15915
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15916 {
15917
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15918 {
15919 return qe_invalid;
15920 }
15921 657968 }
15922 528504 else temp_mapscr->sidewarpindex = 0;
15923
15924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_igetw(&(temp_mapscr->undercombo),f))
15925 {
15926 return qe_invalid;
15927 }
15928
15929
2/2
✓ Branch 0 taken 1161576 times.
✓ Branch 1 taken 24896 times.
1186472 if(Header->zelda_version < 0x193)
15930 {
15931
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_pages[scrind], f))
15932 {
15933 return qe_invalid;
15934 }
15935 24896 }
15936
15937
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15938 {
15939 return qe_invalid;
15940 }
15941
15942
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_igetw(&(temp_mapscr->catchall),f))
15943 {
15944 return qe_invalid;
15945 }
15946
15947
1/2
✓ Branch 0 taken 1186472 times.
✗ Branch 1 not taken.
1186472 if(!p_getc(&(temp_mapscr->flags),f))
15948 {
15949 return qe_invalid;
15950 }
15951
15952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->flags2),f))
15953 {
15954 return qe_invalid;
15955 }
15956
15957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(!p_getc(&(temp_mapscr->flags3),f))
15958 {
15959 return qe_invalid;
15960 }
15961
15962
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15963 //if (version>2)
15964 {
15965
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags4),f))
15966 {
15967 return qe_invalid;
15968 }
15969 657968 }
15970
15971
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15972 {
15973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags5),f))
15974 {
15975 return qe_invalid;
15976 }
15977
15978
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->noreset),f))
15979 {
15980 return qe_invalid;
15981 }
15982
15983
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->nocarry),f))
15984 {
15985 return qe_invalid;
15986 }
15987
15988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(temp_mapscr->flags5&32)
15989 {
15990 temp_mapscr->flags5 &= ~32;
15991 temp_mapscr->noreset |= 48;
15992 }
15993
15994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(version<8)
15995 {
15996 if(temp_mapscr->noreset&1)
15997 {
15998 temp_mapscr->noreset|=8192;
15999 }
16000
16001 if(temp_mapscr->nocarry&1)
16002 {
16003 temp_mapscr->nocarry|=8192;
16004 temp_mapscr->nocarry&=~1;
16005 }
16006 }
16007 657968 }
16008 else
16009 {
16010 528504 temp_mapscr->flags5 = 0;
16011 528504 temp_mapscr->noreset = 0;
16012 528504 temp_mapscr->nocarry = 0;
16013 }
16014
16015
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16016 {
16017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags6),f))
16018 {
16019 return qe_invalid;
16020 }
16021 657968 }
16022
16023
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>5)
16024 {
16025
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags7),f))
16026 {
16027 return qe_invalid;
16028 }
16029
16030
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags8),f))
16031 {
16032 return qe_invalid;
16033 }
16034
16035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->flags9),f))
16036 {
16037 return qe_invalid;
16038 }
16039
16040
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->flags10),f))
16041 {
16042 return qe_invalid;
16043 }
16044
16045
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->csensitive),f))
16046 {
16047 return qe_invalid;
16048 }
16049 657968 }
16050 else
16051 {
16052 528504 temp_mapscr->csensitive=1;
16053 }
16054
16055
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version<14) // August 2007: screen SFX added
16056 {
16057
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16058 {
16059 994 temp_mapscr->bosssfx=
16060
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16061 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16062 WAV_ROAR;
16063 994 }
16064
16065
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16066 {
16067 170 temp_mapscr->oceansfx=WAV_SEA;
16068 170 }
16069
16070 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16071 ? 0 : WAV_SECRET;
16072
16073 528504 temp_mapscr->flags3 &= ~66; //64|2
16074 528504 temp_mapscr->flags2 &= ~32;
16075 528504 temp_mapscr->flags &= ~136; // 128|8
16076 528504 }
16077 else
16078 {
16079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->oceansfx),f))
16080 {
16081 return qe_invalid;
16082 }
16083
16084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->bosssfx),f))
16085 {
16086 return qe_invalid;
16087 }
16088
16089
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->secretsfx),f))
16090 {
16091 return qe_invalid;
16092 }
16093 }
16094
16095
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version<15) // October 2007: another SFX
16096 {
16097 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16098 528504 }
16099 else
16100 {
16101
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16102 {
16103 return qe_invalid;
16104 }
16105 }
16106
16107
16108
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16109 {
16110
2/2
✓ Branch 0 taken 6985776 times.
✓ Branch 1 taken 1164296 times.
8150072 for(int32_t k=0; k<6; k++)
16111 {
16112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16113 {
16114 return qe_invalid;
16115 }
16116 6985776 }
16117
16118
2/2
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 6985776 times.
8150072 for(int32_t k=0; k<6; k++)
16119 {
16120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16121 {
16122 return qe_invalid;
16123 }
16124 6985776 }
16125 1164296 }
16126
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16127 {
16128 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16129 {
16130 return qe_invalid;
16131 }
16132
16133 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16134 {
16135 return qe_invalid;
16136 }
16137
16138 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16139 {
16140 return qe_invalid;
16141 }
16142
16143 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16144
16145 {
16146 return qe_invalid;
16147 }
16148 }
16149
16150
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>149))
16151 {
16152
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16153 {
16154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16155 {
16156 return qe_invalid;
16157 }
16158 16320 }
16159
16160
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16161 {
16162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16163 {
16164 return qe_invalid;
16165 }
16166 16320 }
16167
16168
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16169 {
16170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16171 {
16172 return qe_invalid;
16173 }
16174 16320 }
16175
16176
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16177 {
16178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16179 {
16180 return qe_invalid;
16181 }
16182 16320 }
16183
16184
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16185 {
16186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16187 {
16188 return qe_invalid;
16189 }
16190 16320 }
16191
16192
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16193 {
16194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16195 {
16196 return qe_invalid;
16197 }
16198 16320 }
16199 2720 }
16200
16201
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16202 {
16203
2/2
✓ Branch 0 taken 6985776 times.
✓ Branch 1 taken 1164296 times.
8150072 for(int32_t k=0; k<6; k++)
16204 {
16205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6985776 times.
6985776 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16206 {
16207 return qe_invalid;
16208 }
16209 6985776 }
16210 1164296 }
16211
16212
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16213 {
16214
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 if((Header->zelda_version == 0x192)&&(Header->build>153))
16215 {
16216
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16217 {
16218 return qe_invalid;
16219 }
16220 2720 }
16221
16222
1/2
✓ Branch 0 taken 1164296 times.
✗ Branch 1 not taken.
1164296 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16223 {
16224 return qe_invalid;
16225 }
16226 1164296 }
16227
16228
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16229 {
16230 22176 extras=15;
16231 22176 }
16232
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16233 {
16234 extras=11;
16235 }
16236
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16237 {
16238 extras=32;
16239 }
16240
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16241 {
16242 extras=64;
16243 }
16244
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
1164296 else if(Header->zelda_version < 0x193)
16245 {
16246 2720 extras=62;
16247 2720 }
16248 else
16249
16250 {
16251 1161576 extras=0;
16252 }
16253
16254
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1186472 times.
1687752 for(int32_t k=0; k<extras; k++)
16255 {
16256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16257 {
16258 return qe_invalid;
16259 }
16260 501280 }
16261
16262
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16263 //if (version>3)
16264 {
16265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_getc(&(temp_mapscr->nextmap),f))
16266 {
16267 return qe_invalid;
16268 }
16269
16270
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->nextscr),f))
16271 {
16272 return qe_invalid;
16273 }
16274 657968 }
16275 else
16276 {
16277 528504 temp_mapscr->nextmap=0;
16278 528504 temp_mapscr->nextscr=0;
16279 }
16280
16281
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16282 {
16283 22176 secretcombos=20;
16284 22176 }
16285
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1161576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1164296 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16286 {
16287 secretcombos=256;
16288 }
16289 else
16290 {
16291 1164296 secretcombos=128;
16292 }
16293
16294
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16295 {
16296
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16297 {
16298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16299 {
16300 return qe_invalid;
16301 }
16302
16303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16304 {
16305 443520 temp_mapscr->secretcombo[k]=tempbyte;
16306 443520 }
16307 443520 }
16308 22176 }
16309 else
16310 {
16311
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16312 {
16313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16314 {
16315 return qe_invalid;
16316 }
16317
16318 149029888 }
16319 }
16320
16321
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16322 {
16323
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16324 {
16325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16326 {
16327 return qe_invalid;
16328 }
16329 149029888 }
16330
16331
2/2
✓ Branch 0 taken 149029888 times.
✓ Branch 1 taken 1164296 times.
150194184 for(int32_t k=0; k<128; k++)
16332 {
16333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149029888 times.
149029888 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16334 {
16335 return qe_invalid;
16336 }
16337 149029888 }
16338 1164296 }
16339
16340
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16341 {
16342 if(!p_getc(&padding,f))
16343 {
16344 return qe_invalid;
16345 }
16346 }
16347
16348
2/2
✓ Branch 0 taken 208819072 times.
✓ Branch 1 taken 1186472 times.
210005544 for(int32_t k=0; k<176; k++)
16349 {
16350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208819072 times.
208819072 if(!p_igetw(&(temp_mapscr->data[k]),f))
16351 {
16352 return qe_invalid;
16353 }
16354 208819072 }
16355
16356
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1183752 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16357 {
16358 if(!p_getc(&padding,f))
16359 {
16360 return qe_invalid;
16361 }
16362
16363 if(!p_getc(&padding,f))
16364 {
16365 return qe_invalid;
16366 }
16367 }
16368
16369
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16370 {
16371
2/2
✓ Branch 0 taken 204916096 times.
✓ Branch 1 taken 1164296 times.
206080392 for(int32_t k=0; k<176; k++)
16372 {
16373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204916096 times.
204916096 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16374 {
16375 return qe_invalid;
16376 }
16377
16378
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 204437376 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
204916096 if((Header->zelda_version == 0x192)&&(Header->build<24))
16379 {
16380 if(!p_getc(&tempbyte,f))
16381 {
16382 return qe_invalid;
16383 }
16384
16385 if(!p_getc(&tempbyte,f))
16386 {
16387 return qe_invalid;
16388 }
16389
16390 if(!p_getc(&tempbyte,f))
16391 {
16392 return qe_invalid;
16393 }
16394 }
16395 204916096 }
16396 1164296 }
16397
16398
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1161576 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1186472 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16399 {
16400
2/2
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 204916096 times.
206080392 for(int32_t k=0; k<176; k++)
16401 {
16402
16403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204916096 times.
204916096 if(!p_getc(&(temp_mapscr->cset[k]),f))
16404 {
16405 return qe_invalid;
16406 }
16407 204916096 }
16408 1164296 }
16409
16410
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16411 {
16412 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16413 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_pages[scrind]<<8);
16414 22176 }
16415
16416
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16417 {
16418 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16419 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16420 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16421 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16422 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16423 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16424 22176 }
16425
16426
5/6
✓ Branch 0 taken 1164296 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1161576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1186472 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16427 {
16428
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16429 {
16430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16431 {
16432 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16433 {
16434 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16435 }
16436 }
16437 else
16438 {
16439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16440 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16441 {
16442 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16443 3902976 }
16444
16445 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16446 }
16447
16448 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_pages[scrind]<<8);
16449 3902976 }
16450 22176 }
16451
16452 /*if(version>12)
16453 {
16454 if(!p_getc(&(temp_mapscr->scrWidth),f))
16455 {
16456 return qe_invalid;
16457 }
16458 if(!p_getc(&(temp_mapscr->scrHeight),f))
16459 {
16460 return qe_invalid;
16461 }
16462 }*/
16463
16464
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>4)
16465 {
16466
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16467 {
16468 return qe_invalid;
16469 }
16470 657968 }
16471 else
16472 {
16473 528504 temp_mapscr->screen_midi = -1;
16474 }
16475
16476
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version>=17)
16477 {
16478
1/2
✓ Branch 0 taken 657968 times.
✗ Branch 1 not taken.
657968 if(!p_getc(&(temp_mapscr->lens_layer),f))
16479 {
16480 return qe_invalid;
16481 }
16482 657968 }
16483 else
16484 {
16485 528504 temp_mapscr->lens_layer = llNORMAL;
16486 }
16487
16488
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 657968 times.
1186472 if(version>6)
16489 {
16490 dword bits;
16491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657968 times.
657968 if(!p_igetl(&bits,f))
16492 {
16493 return qe_invalid;
16494 }
16495
16496 int32_t m;
16497 float tempfloat;
16498 word tempw;
16499 657968 temp_mapscr->ffcCountMarkDirty();
16500 657968 temp_mapscr->ffcs.clear();
16501 657968 temp_mapscr->resizeFFC(std::bit_width(bits));
16502
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 21054976 times.
21712944 for(m=0; m<32; m++)
16503 {
16504
2/2
✓ Branch 0 taken 20778977 times.
✓ Branch 1 taken 275999 times.
21054976 if((bits>>m)&1)
16505 {
16506 275999 ffcdata& tempffc = temp_mapscr->ffcs[m];
16507
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(!p_igetw(&tempw,f))
16508 {
16509 return qe_invalid;
16510 }
16511 275999 tempffc.data = tempw;
16512
16513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempffc.cset),f))
16514 {
16515 return qe_invalid;
16516 }
16517
16518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetw(&(tempffc.delay),f))
16519 {
16520 return qe_invalid;
16521 }
16522
16523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(version < 9)
16524 {
16525 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16526 {
16527 return qe_invalid;
16528 }
16529
16530 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16531
16532 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16533 {
16534 return qe_invalid;
16535 }
16536
16537 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16538
16539 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16540 {
16541 return qe_invalid;
16542 }
16543
16544 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16545
16546 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16547 {
16548 return qe_invalid;
16549 }
16550
16551 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16552
16553 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16554 {
16555 return qe_invalid;
16556 }
16557
16558 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16559
16560 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16561 {
16562 return qe_invalid;
16563 }
16564
16565 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16566 }
16567 else
16568 {
16569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.x),f))
16570 {
16571 return qe_invalid;
16572 }
16573
16574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.y),f))
16575 {
16576 return qe_invalid;
16577 }
16578
16579
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(!p_igetzf(&(tempffc.vx),f))
16580 {
16581 return qe_invalid;
16582 }
16583
16584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.vy),f))
16585 {
16586 return qe_invalid;
16587 }
16588
16589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.ax),f))
16590 {
16591 return qe_invalid;
16592 }
16593
16594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetzf(&(tempffc.ay),f))
16595 {
16596 return qe_invalid;
16597 }
16598 }
16599
16600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempffc.link),f))
16601 {
16602 return qe_invalid;
16603 }
16604
16605
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version>7)
16606 {
16607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&tempbyte,f))
16608 {
16609 return qe_invalid;
16610 }
16611
16612 275999 tempffc.hit_width = (tempbyte&0x3F)+1;
16613 275999 tempffc.txsz = (tempbyte>>6)+1;
16614
16615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&tempbyte,f))
16616 {
16617 return qe_invalid;
16618 }
16619
16620 275999 tempffc.hit_height = (tempbyte&0x3F)+1;
16621 275999 tempffc.tysz = (tempbyte>>6)+1;
16622
16623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.flags),f))
16624 {
16625 return qe_invalid;
16626 }
16627 275999 }
16628 else
16629 {
16630 tempffc.hit_width=16;
16631 tempffc.hit_height=16;
16632 tempffc.txsz=1;
16633 tempffc.tysz=1;
16634 tempffc.flags=ffc_none;
16635 }
16636
16637 275999 tempffc.updateSolid();
16638
16639
16640
4/6
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 269995 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 269995 times.
275999 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16641 {
16642 tempffc.flags|=ffc_ignoreholdup;
16643 }
16644
16645
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version>9)
16646 {
16647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetw(&(tempffc.script),f))
16648 {
16649 return qe_invalid;
16650 }
16651 275999 }
16652 else
16653 {
16654 tempffc.script=0;
16655 }
16656
16657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(version>10)
16658 {
16659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[0]),f))
16660 {
16661 return qe_invalid;
16662 }
16663
16664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[1]),f))
16665 {
16666 return qe_invalid;
16667 }
16668
16669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[2]),f))
16670 {
16671 return qe_invalid;
16672 }
16673
16674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[3]),f))
16675 {
16676 return qe_invalid;
16677 }
16678
16679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[4]),f))
16680 {
16681 return qe_invalid;
16682 }
16683
16684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[5]),f))
16685 {
16686 return qe_invalid;
16687 }
16688
16689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[6]),f))
16690 {
16691 return qe_invalid;
16692 }
16693
16694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_igetl(&(tempffc.initd[7]),f))
16695 {
16696 return qe_invalid;
16697 }
16698
16699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempbyte),f))
16700 {
16701 return qe_invalid;
16702 }
16703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275999 times.
275999 if(!p_getc(&(tempbyte),f))
16704 {
16705 return qe_invalid;
16706 }
16707 275999 }
16708
16709
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16710 {
16711 tempffc.script = 0;
16712 for(int q = 0; q < 8; ++q)
16713 tempffc.initd[q] = 0;
16714 }
16715
1/2
✓ Branch 0 taken 275999 times.
✗ Branch 1 not taken.
275999 if(version <= 11)
16716 {
16717 fixffcs=true;
16718 }
16719 275999 }
16720 21054976 }
16721
16722 657968 temp_mapscr->shinkToFitFFCs();
16723 657968 }
16724
16725
16726 //add in the new whistle flags
16727
2/2
✓ Branch 0 taken 657968 times.
✓ Branch 1 taken 528504 times.
1186472 if(version<13)
16728 {
16729
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16730 {
16731 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16732 124 }
16733 528504 }
16734
16735 //2.55 starts here
16736
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 19 && Header->zelda_version > 0x253 )
16737 {
16738 // mapscr fields that were never used, so are now removed:
16739 // int32_t npcstrings[10];
16740 // int16_t new_items[10];
16741 // int16_t new_item_x[10];
16742 // int16_t new_item_y[10];
16743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16744 {
16745 return qe_invalid;
16746 }
16747 34408 }
16748
16749
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 20 && Header->zelda_version > 0x253 )
16750 {
16751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16752 {
16753 return qe_invalid;
16754 }
16755
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16756 {
16757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16758 {
16759 return qe_invalid;
16760 }
16761 275264 }
16762 34408 }
16763
2/2
✓ Branch 0 taken 1152064 times.
✓ Branch 1 taken 34408 times.
1186472 if ( version < 20 )
16764 {
16765 1152064 temp_mapscr->script = 0;
16766
2/2
✓ Branch 0 taken 9216512 times.
✓ Branch 1 taken 1152064 times.
10368576 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16767 1152064 }
16768
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 21 && Header->zelda_version > 0x253 )
16769 {
16770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16771 {
16772 return qe_invalid;
16773 }
16774 34408 }
16775
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
1186472 if ( version < 21 )
16776 {
16777 1152064 temp_mapscr->preloadscript = 0;
16778 1152064 }
16779
16780
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1186472 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16781 {
16782
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16783 {
16784 return qe_invalid;
16785 }
16786
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16787 {
16788 return qe_invalid;
16789 }
16790 34408 }
16791
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1152064 times.
1186472 if ( version < 22 )
16792 {
16793 1152064 temp_mapscr->hidelayers = 0;
16794 1152064 temp_mapscr->hidescriptlayers = 0;
16795 1152064 }
16796
16797 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16798 //May be any version before 2.11. -Z
16799 /* --not the roar, the HIT SFX
16800 if ( Header->zelda_version <= 0x210 )
16801 {
16802 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16803 {
16804 temp_mapscr->bosssfx = WAV_ROAR;
16805 }
16806 }
16807 */
16808
2/2
✓ Branch 0 taken 4745888 times.
✓ Branch 1 taken 1186472 times.
5932360 for(int32_t k=0; k<4; k++)
16809 {
16810
1/2
✓ Branch 0 taken 4745888 times.
✗ Branch 1 not taken.
4745888 if(temp_mapscr->door[k] == dNONE)
16811 temp_mapscr->door[k] = dWALL;
16812 4745888 }
16813
16814 1186472 return 0;
16815 1186472 }
16816 1385440 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16817 {
16818
2/2
✓ Branch 0 taken 1186472 times.
✓ Branch 1 taken 198968 times.
1385440 if(version < 23)
16819 {
16820 1186472 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186472 times.
1186472 if(ret) return ret;
16822 1186472 }
16823 else
16824 {
16825
1/2
✓ Branch 0 taken 198968 times.
✗ Branch 1 not taken.
198968 if(!p_getc(&(temp_mapscr->valid),f))
16826 return qe_invalid;
16827
2/2
✓ Branch 0 taken 105490 times.
✓ Branch 1 taken 93478 times.
198968 if(!(temp_mapscr->valid & mVALID))
16828 {
16829 93478 int map = scrind/MAPSCRS;
16830 93478 int screen = scrind%MAPSCRS;
16831
4/6
✓ Branch 0 taken 86376 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 86376 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86376 times.
93478 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16832 {
16833 //Empty screen, apply autolayers
16834
2/2
✓ Branch 0 taken 518256 times.
✓ Branch 1 taken 86376 times.
604632 for(int q = 0; q < 6; ++q)
16835 {
16836 518256 auto layermap = map_autolayers[map*6+q];
16837 518256 temp_mapscr->layermap[q] = layermap;
16838
2/2
✓ Branch 0 taken 503100 times.
✓ Branch 1 taken 15156 times.
518256 if(layermap)
16839 15156 temp_mapscr->layerscreen[q] = screen;
16840 518256 }
16841 86376 }
16842 93478 return 0;
16843 }
16844 uint32_t scr_has_flags;
16845
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_igetl(&scr_has_flags,f))
16846 return qe_invalid;
16847
16848
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 95032 times.
105490 if(scr_has_flags & SCRHAS_ROOMDATA)
16849 {
16850
1/2
✓ Branch 0 taken 95032 times.
✗ Branch 1 not taken.
95032 if(!p_getc(&(temp_mapscr->guy),f))
16851 return qe_invalid;
16852
2/2
✓ Branch 0 taken 94912 times.
✓ Branch 1 taken 120 times.
95032 if(version > 26)
16853 {
16854
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_igetl(&(temp_mapscr->guytile),f))
16855 return qe_invalid;
16856
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_getc(&(temp_mapscr->guycs),f))
16857 return qe_invalid;
16858
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_igetw(&(temp_mapscr->roomflags),f))
16859 return qe_invalid;
16860 94912 }
16861 else
16862 {
16863 120 temp_mapscr->guytile = -1; //signal to use default guy values
16864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16865
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16866 }
16867
1/2
✓ Branch 0 taken 95032 times.
✗ Branch 1 not taken.
95032 if(!p_igetw(&(temp_mapscr->str),f))
16868 return qe_invalid;
16869
1/2
✓ Branch 0 taken 95032 times.
✗ Branch 1 not taken.
95032 if(!p_getc(&(temp_mapscr->room),f))
16870 return qe_invalid;
16871
1/2
✓ Branch 0 taken 95032 times.
✗ Branch 1 not taken.
95032 if(!p_igetw(&(temp_mapscr->catchall),f))
16872 return qe_invalid;
16873 95032 }
16874
2/2
✓ Branch 0 taken 103148 times.
✓ Branch 1 taken 2342 times.
105490 if(scr_has_flags & SCRHAS_ITEM)
16875 {
16876
1/2
✓ Branch 0 taken 2342 times.
✗ Branch 1 not taken.
2342 if(!p_getc(&(temp_mapscr->item),f))
16877 return qe_invalid;
16878
1/2
✓ Branch 0 taken 2342 times.
✗ Branch 1 not taken.
2342 if(!p_getc(&(temp_mapscr->hasitem),f))
16879 return qe_invalid;
16880
1/2
✓ Branch 0 taken 2342 times.
✗ Branch 1 not taken.
2342 if(!p_getc(&(temp_mapscr->itemx),f))
16881 return qe_invalid;
16882
1/2
✓ Branch 0 taken 2342 times.
✗ Branch 1 not taken.
2342 if(!p_getc(&(temp_mapscr->itemy),f))
16883 return qe_invalid;
16884 2342 }
16885
2/2
✓ Branch 0 taken 94855 times.
✓ Branch 1 taken 10635 times.
105490 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16886 {
16887
1/2
✓ Branch 0 taken 10635 times.
✗ Branch 1 not taken.
10635 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16888 return qe_invalid;
16889 10635 }
16890
2/2
✓ Branch 0 taken 103020 times.
✓ Branch 1 taken 2470 times.
105490 if(scr_has_flags & SCRHAS_TWARP)
16891 {
16892
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 2470 times.
12350 for(int32_t i=0; i<4; i++)
16893 {
16894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9880 times.
9880 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16895 return qe_invalid;
16896 9880 }
16897
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 2470 times.
12350 for(int32_t i=0; i<4; i++)
16898 {
16899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9880 times.
9880 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16900 return qe_invalid;
16901 9880 }
16902
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 2470 times.
12350 for(int32_t i=0; i<4; i++)
16903 {
16904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9880 times.
9880 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16905 return qe_invalid;
16906 9880 }
16907
1/2
✓ Branch 0 taken 2470 times.
✗ Branch 1 not taken.
2470 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16908 return qe_invalid;
16909 2470 }
16910
2/2
✓ Branch 0 taken 96851 times.
✓ Branch 1 taken 8639 times.
105490 if(scr_has_flags & SCRHAS_SWARP)
16911 {
16912
2/2
✓ Branch 0 taken 34556 times.
✓ Branch 1 taken 8639 times.
43195 for(int32_t i=0; i<4; i++)
16913 {
16914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34556 times.
34556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16915 return qe_invalid;
16916 34556 }
16917
2/2
✓ Branch 0 taken 34556 times.
✓ Branch 1 taken 8639 times.
43195 for(int32_t i=0; i<4; i++)
16918 {
16919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34556 times.
34556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16920 return qe_invalid;
16921 34556 }
16922
2/2
✓ Branch 0 taken 34556 times.
✓ Branch 1 taken 8639 times.
43195 for(int32_t i=0; i<4; i++)
16923 {
16924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34556 times.
34556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16925 return qe_invalid;
16926 34556 }
16927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8639 times.
8639 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16928 return qe_invalid;
16929
1/2
✓ Branch 0 taken 8639 times.
✗ Branch 1 not taken.
8639 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16930 return qe_invalid;
16931 8639 }
16932
2/2
✓ Branch 0 taken 98992 times.
✓ Branch 1 taken 6498 times.
105490 if(scr_has_flags & SCRHAS_WARPRET)
16933 {
16934
2/2
✓ Branch 0 taken 25992 times.
✓ Branch 1 taken 6498 times.
32490 for(int32_t i=0; i<4; i++)
16935 {
16936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25992 times.
25992 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16937 return qe_invalid;
16938 25992 }
16939
2/2
✓ Branch 0 taken 25992 times.
✓ Branch 1 taken 6498 times.
32490 for(int32_t i=0; i<4; i++)
16940 {
16941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25992 times.
25992 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16942 return qe_invalid;
16943 25992 }
16944
1/2
✓ Branch 0 taken 6498 times.
✗ Branch 1 not taken.
6498 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16945 return qe_invalid;
16946
1/2
✓ Branch 0 taken 6498 times.
✗ Branch 1 not taken.
6498 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16947 return qe_invalid;
16948 6498 }
16949
2/2
✓ Branch 0 taken 92003 times.
✓ Branch 1 taken 13487 times.
105490 if(scr_has_flags & SCRHAS_LAYERS)
16950 {
16951
2/2
✓ Branch 0 taken 80922 times.
✓ Branch 1 taken 13487 times.
94409 for(int32_t k=0; k<6; k++)
16952 {
16953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80922 times.
80922 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16954 return qe_invalid;
16955 80922 }
16956
2/2
✓ Branch 0 taken 80922 times.
✓ Branch 1 taken 13487 times.
94409 for(int32_t k=0; k<6; k++)
16957 {
16958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80922 times.
80922 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16959 return qe_invalid;
16960 80922 }
16961
2/2
✓ Branch 0 taken 80922 times.
✓ Branch 1 taken 13487 times.
94409 for(int32_t k=0; k<6; k++)
16962 {
16963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80922 times.
80922 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16964 return qe_invalid;
16965 80922 }
16966
1/2
✓ Branch 0 taken 13487 times.
✗ Branch 1 not taken.
13487 if(!p_getc(&(temp_mapscr->hidelayers),f))
16967 return qe_invalid;
16968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13487 times.
13487 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16969 return qe_invalid;
16970 13487 }
16971
2/2
✓ Branch 0 taken 105386 times.
✓ Branch 1 taken 104 times.
105490 if(scr_has_flags & SCRHAS_MAZE)
16972 {
16973
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
16974 {
16975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
16976 return qe_invalid;
16977 416 }
16978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
16979 return qe_invalid;
16980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
16981 {
16982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
16983 return qe_invalid;
16984 104 }
16985 104 }
16986
2/2
✓ Branch 0 taken 76984 times.
✓ Branch 1 taken 28506 times.
105490 if(scr_has_flags & SCRHAS_D_S_U)
16987 {
16988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76984 times.
76984 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16989 return qe_invalid;
16990
2/2
✓ Branch 0 taken 307936 times.
✓ Branch 1 taken 76984 times.
384920 for(int32_t k=0; k<4; k++)
16991 {
16992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 307936 times.
307936 if(!p_getc(&(temp_mapscr->door[k]),f))
16993 return qe_invalid;
16994
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 307576 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
307936 if(version < 29 && temp_mapscr->door[k] == dNONE)
16995 temp_mapscr->door[k] = dWALL;
16996 307936 }
16997
16998
1/2
✓ Branch 0 taken 76984 times.
✗ Branch 1 not taken.
76984 if(!p_getc(&(temp_mapscr->stairx),f))
16999 return qe_invalid;
17000
17001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76984 times.
76984 if(!p_getc(&(temp_mapscr->stairy),f))
17002 return qe_invalid;
17003
1/2
✓ Branch 0 taken 76984 times.
✗ Branch 1 not taken.
76984 if(!p_igetw(&(temp_mapscr->undercombo),f))
17004 return qe_invalid;
17005
1/2
✓ Branch 0 taken 76984 times.
✗ Branch 1 not taken.
76984 if(!p_getc(&(temp_mapscr->undercset),f))
17006 return qe_invalid;
17007 76984 }
17008
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 18018 times.
28506 else if(version < 29)
17009 {
17010
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17011 41952 temp_mapscr->door[k] = dWALL;
17012 10488 }
17013
2/2
✓ Branch 0 taken 99059 times.
✓ Branch 1 taken 6431 times.
105490 if(scr_has_flags & SCRHAS_FLAGS)
17014 {
17015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6431 times.
6431 if(!p_getc(&(temp_mapscr->flags),f))
17016 return qe_invalid;
17017
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags2),f))
17018 return qe_invalid;
17019
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags3),f))
17020 return qe_invalid;
17021
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags4),f))
17022 return qe_invalid;
17023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6431 times.
6431 if(!p_getc(&(temp_mapscr->flags5),f))
17024 return qe_invalid;
17025
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags6),f))
17026 return qe_invalid;
17027
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags7),f))
17028 return qe_invalid;
17029
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags8),f))
17030 return qe_invalid;
17031
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags9),f))
17032 return qe_invalid;
17033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6431 times.
6431 if(!p_getc(&(temp_mapscr->flags10),f))
17034 return qe_invalid;
17035
1/2
✓ Branch 0 taken 6431 times.
✗ Branch 1 not taken.
6431 if(!p_getc(&(temp_mapscr->flags11),f))
17036 return qe_invalid;
17037 6431 }
17038
2/2
✓ Branch 0 taken 100226 times.
✓ Branch 1 taken 5264 times.
105490 if(scr_has_flags & SCRHAS_ENEMY)
17039 {
17040
2/2
✓ Branch 0 taken 52640 times.
✓ Branch 1 taken 5264 times.
57904 for(int32_t k=0; k<10; k++)
17041 {
17042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52640 times.
52640 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17043 return qe_invalid;
17044
1/2
✓ Branch 0 taken 52640 times.
✗ Branch 1 not taken.
52640 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17045 temp_mapscr->enemy[k] = 0;
17046 52640 }
17047
1/2
✓ Branch 0 taken 5264 times.
✗ Branch 1 not taken.
5264 if(!p_getc(&(temp_mapscr->pattern),f))
17048 return qe_invalid;
17049 5264 }
17050
2/2
✓ Branch 0 taken 105085 times.
✓ Branch 1 taken 405 times.
105490 if(scr_has_flags & SCRHAS_CARRY)
17051 {
17052
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->noreset),f))
17053 return qe_invalid;
17054
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->nocarry),f))
17055 return qe_invalid;
17056
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->nextmap),f))
17057 return qe_invalid;
17058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->nextscr),f))
17059 return qe_invalid;
17060 405 }
17061
2/2
✓ Branch 0 taken 104919 times.
✓ Branch 1 taken 571 times.
105490 if(scr_has_flags & SCRHAS_SCRIPT)
17062 {
17063
1/2
✓ Branch 0 taken 571 times.
✗ Branch 1 not taken.
571 if(!p_igetw(&(temp_mapscr->script),f))
17064 return qe_invalid;
17065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 571 times.
571 if(!p_getc(&(temp_mapscr->preloadscript),f))
17066 return qe_invalid;
17067
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 571 times.
5139 for ( int32_t q = 0; q < 8; q++ )
17068 {
17069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4568 times.
4568 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17070 return qe_invalid;
17071 4568 }
17072 571 }
17073
2/2
✓ Branch 0 taken 74061 times.
✓ Branch 1 taken 31429 times.
105490 if(scr_has_flags & SCRHAS_SECRETS)
17074 {
17075
2/2
✓ Branch 0 taken 4022912 times.
✓ Branch 1 taken 31429 times.
4054341 for(int32_t k=0; k<128; k++)
17076 {
17077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4022912 times.
4022912 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17078 return qe_invalid;
17079 4022912 }
17080
2/2
✓ Branch 0 taken 4022912 times.
✓ Branch 1 taken 31429 times.
4054341 for(int32_t k=0; k<128; k++)
17081 {
17082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4022912 times.
4022912 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17083 return qe_invalid;
17084 4022912 }
17085
2/2
✓ Branch 0 taken 4022912 times.
✓ Branch 1 taken 31429 times.
4054341 for(int32_t k=0; k<128; k++)
17086 {
17087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4022912 times.
4022912 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17088 return qe_invalid;
17089 4022912 }
17090 31429 }
17091
2/2
✓ Branch 0 taken 40658 times.
✓ Branch 1 taken 64832 times.
105490 if(scr_has_flags & SCRHAS_COMBOFLAG)
17092 {
17093
2/2
✓ Branch 0 taken 11410432 times.
✓ Branch 1 taken 64832 times.
11475264 for(int32_t k=0; k<176; ++k)
17094 {
17095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11410432 times.
11410432 if(!p_igetw(&(temp_mapscr->data[k]),f))
17096 return qe_invalid;
17097 11410432 }
17098
2/2
✓ Branch 0 taken 11410432 times.
✓ Branch 1 taken 64832 times.
11475264 for(int32_t k=0; k<176; ++k)
17099 {
17100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11410432 times.
11410432 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17101 return qe_invalid;
17102 11410432 }
17103
2/2
✓ Branch 0 taken 11410432 times.
✓ Branch 1 taken 64832 times.
11475264 for(int32_t k=0; k<176; ++k)
17104 {
17105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11410432 times.
11410432 if(!p_getc(&(temp_mapscr->cset[k]),f))
17106 return qe_invalid;
17107 11410432 }
17108 64832 }
17109
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(scr_has_flags & SCRHAS_MISC)
17110 {
17111
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_igetw(&(temp_mapscr->color),f))
17112 return qe_invalid;
17113
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->csensitive),f))
17114 return qe_invalid;
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105490 times.
105490 if(!p_getc(&(temp_mapscr->oceansfx),f))
17116 return qe_invalid;
17117
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->bosssfx),f))
17118 return qe_invalid;
17119
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->secretsfx),f))
17120 return qe_invalid;
17121
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17122 return qe_invalid;
17123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105490 times.
105490 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17124 return qe_invalid;
17125
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17126 return qe_invalid;
17127
1/2
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
105490 if(!p_getc(&(temp_mapscr->lens_layer),f))
17128 return qe_invalid;
17129
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 94912 times.
105490 if(version > 27)
17130 {
17131
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_getc(&(temp_mapscr->lens_show),f))
17132 return qe_invalid;
17133
1/2
✓ Branch 0 taken 94912 times.
✗ Branch 1 not taken.
94912 if(!p_getc(&(temp_mapscr->lens_hide),f))
17134 return qe_invalid;
17135 94912 }
17136 105490 }
17137 else
17138 {
17139 temp_mapscr->screen_midi = -1;
17140 temp_mapscr->csensitive = 1;
17141 }
17142 //FFC
17143 105490 bool old_ff = version < 25;
17144 105490 dword bits = 0;
17145 105490 word numffc = 32;
17146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105490 times.
105490 if(old_ff)
17147 {
17148 if(!p_igetl(&bits,f))
17149 return qe_invalid;
17150 }
17151 else
17152 {
17153
2/4
✓ Branch 0 taken 105490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105490 times.
105490 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17154 return qe_invalid;
17155 }
17156
17157 105490 temp_mapscr->ffcCountMarkDirty();
17158 105490 temp_mapscr->ffcs.clear();
17159 105490 temp_mapscr->resizeFFC(numffc);
17160
17161 byte tempbyte;
17162 word tempw;
17163
4/6
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 105339 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 151 times.
105490 static ffcdata nil_ffc;
17164
2/2
✓ Branch 0 taken 1981419 times.
✓ Branch 1 taken 105490 times.
2086909 for(word m = 0; m < numffc; ++m)
17165 {
17166
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1981419 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1981419 if(old_ff && !(bits & (1<<m))) continue;
17167
17168
1/2
✓ Branch 0 taken 1981419 times.
✗ Branch 1 not taken.
1981419 ffcdata& tempffc = (m < MAXFFCS)
17169 1981419 ? temp_mapscr->ffcs[m]
17170 : nil_ffc; //sanity
17171
17172
1/2
✓ Branch 0 taken 1981419 times.
✗ Branch 1 not taken.
1981419 if(!p_igetw(&tempw,f))
17173 return qe_invalid;
17174
3/4
✓ Branch 0 taken 1981419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14009 times.
✓ Branch 3 taken 1967410 times.
1981419 if(!old_ff && !tempw) //empty ffc, nothing more to load
17175 1967410 continue;
17176 14009 tempffc.data = tempw;
17177
17178
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_getc(&(tempffc.cset),f))
17179 return qe_invalid;
17180
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetw(&(tempffc.delay),f))
17181 return qe_invalid;
17182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_igetzf(&(tempffc.x),f))
17183 return qe_invalid;
17184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_igetzf(&(tempffc.y),f))
17185 return qe_invalid;
17186
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetzf(&(tempffc.vx),f))
17187 return qe_invalid;
17188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_igetzf(&(tempffc.vy),f))
17189 return qe_invalid;
17190
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetzf(&(tempffc.ax),f))
17191 return qe_invalid;
17192
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetzf(&(tempffc.ay),f))
17193 return qe_invalid;
17194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_getc(&(tempffc.link),f))
17195 return qe_invalid;
17196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(version < 24)
17197 {
17198 if(!p_getc(&tempbyte,f))
17199 return qe_invalid;
17200 tempffc.hit_width = (tempbyte&0x3F)+1;
17201 tempffc.txsz = (tempbyte>>6)+1;
17202 if(!p_getc(&tempbyte,f))
17203 return qe_invalid;
17204 tempffc.hit_height = (tempbyte&0x3F)+1;
17205 tempffc.tysz = (tempbyte>>6)+1;
17206 }
17207 else
17208 {
17209
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetl(&(tempffc.hit_width),f))
17210 return qe_invalid;
17211
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetl(&(tempffc.hit_height),f))
17212 return qe_invalid;
17213
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_getc(&(tempffc.txsz),f))
17214 return qe_invalid;
17215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_getc(&(tempffc.tysz),f))
17216 return qe_invalid;
17217 }
17218
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(!p_igetl(&(tempffc.flags),f))
17219 return qe_invalid;
17220 14009 tempffc.updateSolid();
17221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14009 times.
14009 if(!p_igetw(&(tempffc.script),f))
17222 return qe_invalid;
17223
2/2
✓ Branch 0 taken 112072 times.
✓ Branch 1 taken 14009 times.
126081 for(auto q = 0; q < 8; ++q)
17224 {
17225
1/2
✓ Branch 0 taken 112072 times.
✗ Branch 1 not taken.
112072 if(!p_igetl(&(tempffc.initd[q]),f))
17226 return qe_invalid;
17227 112072 }
17228
2/2
✓ Branch 0 taken 8011 times.
✓ Branch 1 taken 5998 times.
14009 if(version < 33)
17229 {
17230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17231 return qe_invalid;
17232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17233 return qe_invalid;
17234 8011 }
17235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5998 times.
5998 else if(!p_getc(&(tempffc.layer),f))
17236 return qe_invalid;
17237
17238
1/2
✓ Branch 0 taken 14009 times.
✗ Branch 1 not taken.
14009 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17239 {
17240 tempffc.script = 0;
17241 for(int q = 0; q < 8; ++q)
17242 tempffc.initd[q] = 0;
17243 }
17244 14009 }
17245 //END FFC
17246
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 66993 times.
105490 if(version > 29)
17247
1/2
✓ Branch 0 taken 66993 times.
✗ Branch 1 not taken.
66993 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17248 return qe_invalid;
17249 }
17250
17251 1291962 temp_mapscr->shinkToFitFFCs();
17252
17253 1291962 return 0;
17254 1385440 }
17255
17256 470 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17257 {
17258
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17259 470 int32_t screen=0;
17260
17261 470 word version=0;
17262 dword dummy;
17263 int32_t screens_to_read;
17264
17265 470 mapscr temp_mapscr{};
17266 word temp_map_count;
17267 dword section_size;
17268
17269
5/6
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 446 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
470 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17270 {
17271 18 screens_to_read=MAPSCRS192b136;
17272 18 }
17273 else
17274 {
17275 452 screens_to_read=MAPSCRS;
17276 }
17277
17278
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 if(Header->zelda_version > 0x192)
17279 {
17280 //section version info
17281
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&version,f))
17282 {
17283 return qe_invalid;
17284 }
17285
17286 446 FFCore.quest_format[vMaps] = version;
17287
17288
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&dummy,f))
17289 {
17290 return qe_invalid;
17291 }
17292
17293 //section size
17294
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&section_size,f))
17295 {
17296 return qe_invalid;
17297 }
17298
17299 //finally... section data
17300
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&temp_map_count,f))
17301 {
17302 return 5;
17303 }
17304 446 }
17305 else
17306 {
17307 24 temp_map_count=map_count;
17308 }
17309
17310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 470 times.
470 if (temp_map_count > MAXMAPS)
17311 {
17312 return qe_invalid;
17313 }
17314
17315
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 1 times.
470 if (!should_skip)
17316 {
17317 469 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17318 469 TheMaps.clear();
17319
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 TheMaps.resize(_mapsSize);
17320 469 old_combo_pages.clear();
17321
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 old_combo_pages.resize(_mapsSize);
17322 469 map_autolayers.clear();
17323
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 map_autolayers.resize(temp_map_count*6);
17324
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 137 times.
469 if(version >= 31)
17325 137 Regions = {};
17326 469 }
17327
17328
4/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 10325 times.
✓ Branch 2 taken 10325 times.
✓ Branch 3 taken 470 times.
10795 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17329 {
17330 10325 byte valid=1;
17331
2/2
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 8729 times.
10325 if(version > 22)
17332 {
17333
2/4
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1596 times.
✗ Branch 3 not taken.
1596 if(!p_getc(&valid,f))
17334 return qe_invalid;
17335 1596 }
17336
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 10192 times.
10325 if(valid)
17337 {
17338
2/2
✓ Branch 0 taken 8859 times.
✓ Branch 1 taken 1333 times.
10192 if (version > 25)
17339 {
17340
2/2
✓ Branch 0 taken 7998 times.
✓ Branch 1 taken 1333 times.
9331 for(int q = 0; q < 6; ++q)
17341 {
17342
2/4
✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7998 times.
✗ Branch 3 not taken.
7998 if(!p_igetw(&map_autolayers[i*6+q],f))
17343 return qe_invalid;
17344 7998 }
17345 1333 }
17346
17347
2/2
✓ Branch 0 taken 9301 times.
✓ Branch 1 taken 891 times.
10192 if (version >= 31)
17348 {
17349 static regions_data tmp_rd;
17350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 891 times.
891 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17351
2/2
✓ Branch 0 taken 7128 times.
✓ Branch 1 taken 891 times.
8019 for(int32_t j=0; j<8; j++)
17352 {
17353
2/2
✓ Branch 0 taken 57024 times.
✓ Branch 1 taken 7128 times.
64152 for(int32_t k=0; k<8; k++)
17354 {
17355
2/4
✓ Branch 0 taken 57024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57024 times.
✗ Branch 3 not taken.
57024 if(!p_getc(&rd.region_ids[j][k],f))
17356 {
17357 return qe_invalid;
17358 }
17359 57024 }
17360 7128 }
17361 891 }
17362 10192 }
17363
2/2
✓ Branch 0 taken 1403528 times.
✓ Branch 1 taken 10325 times.
1413853 for(int32_t j=0; j<screens_to_read; j++)
17364 {
17365 1403528 screen=i*MAPSCRS+j;
17366
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1403256 times.
1403528 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17367 1403528 scr->map = i;
17368 1403528 scr->screen = j;
17369
2/2
✓ Branch 0 taken 1385440 times.
✓ Branch 1 taken 18088 times.
1403528 if(valid)
17370
1/2
✓ Branch 0 taken 1385440 times.
✗ Branch 1 not taken.
1385440 readmapscreen(f, Header, scr, version, screen);
17371
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 else if (!should_skip)
17372
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 clear_screen(scr);
17373 1403528 }
17374
17375
2/2
✓ Branch 0 taken 10323 times.
✓ Branch 1 taken 2 times.
10325 if (should_skip)
17376 2 continue;
17377
17378
5/6
✓ Branch 0 taken 10155 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10137 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10323 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17379 {
17380 168 int32_t index = (i*MAPSCRS+132);
17381
17382
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17383
17384 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17385 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17386 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17387
17388
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17389 {
17390 504 screen=i*MAPSCRS+j;
17391
17392
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17393 504 TheMaps[screen].valid = mVERSION;
17394 504 TheMaps[screen].screen_midi = -1;
17395 504 TheMaps[screen].csensitive = 1;
17396 504 }
17397 168 }
17398
17399
5/6
✓ Branch 0 taken 10155 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10137 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10323 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17400 {
17401
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17402 {
17403 22848 screen=i*MAPSCRS+j;
17404
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17405
17406
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17407 {
17408
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17409
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17410
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17411 2924544 }
17412 22848 }
17413 168 }
17414 10323 }
17415 470 map_count = temp_map_count;
17416 470 return 0;
17417 470 }
17418
17419
17420 9020063 void update_combo(newcombo& cmb, word section_version)
17421 {
17422
2/2
✓ Branch 0 taken 1218517 times.
✓ Branch 1 taken 7801546 times.
9020063 if(section_version < 40)
17423 {
17424
3/3
✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 46100 times.
✓ Branch 2 taken 7750278 times.
7801546 switch(cmb.type)
17425 {
17426 case cWATER: case cSHALLOWWATER:
17427 46100 cmb.attribytes[6] = iwRipples;
17428 46100 break;
17429 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17430 5168 cmb.attribytes[6] = iwTallGrass;
17431 5168 break;
17432 }
17433 7801546 }
17434
2/2
✓ Branch 0 taken 871086 times.
✓ Branch 1 taken 8148977 times.
9020063 if(section_version < 49)
17435 {
17436
4/4
✓ Branch 0 taken 8113766 times.
✓ Branch 1 taken 35211 times.
✓ Branch 2 taken 15697 times.
✓ Branch 3 taken 8098069 times.
8148977 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17437 50908 cmb.sfx_landing = WAV_ZN1SPLASH;
17438 8148977 }
17439 9020063 }
17440 293 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17441 {
17442
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 269 times.
293 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17443 byte tempbyte;
17444
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 292 times.
293 if (!should_skip)
17445 {
17446 292 reset_all_combo_animations();
17447 292 init_combo_classes();
17448 292 }
17449
17450 // combos
17451 293 word combos_used=0;
17452 int32_t dummy;
17453 byte padding;
17454 293 newcombo temp_combo;
17455
17456
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 292 times.
293 if (!should_skip)
17457
2/2
✓ Branch 0 taken 19061760 times.
✓ Branch 1 taken 292 times.
19062052 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17458
1/2
✓ Branch 0 taken 19061760 times.
✗ Branch 1 not taken.
19062052 combobuf[q].clear();
17459
17460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if(version < 0x174)
17461 {
17462 combos_used=1024;
17463 }
17464
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 18 times.
293 else if(version < 0x191)
17465 {
17466 18 combos_used=2048;
17467 18 }
17468 else
17469 {
17470
2/4
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275 times.
✗ Branch 3 not taken.
275 if(!p_igetw(&combos_used,f))
17471 {
17472 return qe_invalid;
17473 }
17474 }
17475
17476 //finally... section data
17477
2/2
✓ Branch 0 taken 7666530 times.
✓ Branch 1 taken 293 times.
7666823 for(int32_t i=0; i<combos_used; i++)
17478 {
17479
1/2
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
7666530 temp_combo.clear();
17480
1/2
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
7666530 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17481
17482
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if ( section_version >= 11 )
17483 {
17484
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17485 {
17486 return qe_invalid;
17487 }
17488 202968 }
17489 else
17490 {
17491
2/4
✓ Branch 0 taken 7463562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7463562 times.
✗ Branch 3 not taken.
7463562 if(!p_igetw(&temp_combo.tile,f))
17492 {
17493 return qe_invalid;
17494 }
17495 }
17496 7666530 temp_combo.o_tile = temp_combo.tile;
17497
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.flip,f))
17498 {
17499 return qe_invalid;
17500 }
17501
17502
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.walk,f))
17503 {
17504 return qe_invalid;
17505 }
17506
17507
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.type,f))
17508 {
17509 return qe_invalid;
17510 }
17511
17512
2/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7666530 times.
✗ Branch 3 not taken.
7666530 if(!p_getc(&temp_combo.csets,f))
17513 {
17514 return qe_invalid;
17515 }
17516
17517
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7596756 times.
7666530 if(version < 0x193)
17518 {
17519
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17520 return qe_invalid;
17521
17522
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17523 return qe_invalid;
17524
17525
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17526 {
17527
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17528 {
17529 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17530 {
17531 if(!p_getc(&padding,f))
17532 return qe_invalid;
17533 }
17534 }
17535 36864 }
17536 69774 }
17537
2/2
✓ Branch 0 taken 7629666 times.
✓ Branch 1 taken 36864 times.
7666530 if(version >= 0x192)
17538 {
17539
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.frames,f))
17540 return qe_invalid;
17541
17542
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.speed,f))
17543 return qe_invalid;
17544
17545
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_igetw(&temp_combo.nextcombo,f))
17546 return qe_invalid;
17547
17548
2/4
✓ Branch 0 taken 7629666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7629666 times.
✗ Branch 3 not taken.
7629666 if(!p_getc(&temp_combo.nextcset,f))
17549 return qe_invalid;
17550
17551 //Base flag
17552
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=3)
17553
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.flag,f))
17554 return qe_invalid;
17555
17556
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=4)
17557 {
17558
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.skipanim,f))
17559 return qe_invalid;
17560
17561
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_igetw(&temp_combo.nexttimer,f))
17562 return qe_invalid;
17563 4741258 }
17564
17565
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=5)
17566
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.skipanimy,f))
17567 return qe_invalid;
17568
17569
2/2
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2888408 times.
7629666 if(section_version>=6)
17570 {
17571
2/4
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4741258 times.
✗ Branch 3 not taken.
4741258 if(!p_getc(&temp_combo.animflags,f))
17572 return qe_invalid;
17573
17574
1/2
✓ Branch 0 taken 4741258 times.
✗ Branch 1 not taken.
4741258 if(section_version == 6)
17575 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17576 4741258 }
17577
17578
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=8) //combo Attributes[4] and userflags.
17579 {
17580
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17581
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17582 return qe_invalid;
17583
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17584 return qe_invalid;
17585
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17586
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17587 return qe_invalid;
17588 202968 }
17589
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=10) //combo trigger flags
17590 {
17591
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17592
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17593 return qe_invalid;
17594 202968 }
17595
1/2
✓ Branch 0 taken 7426698 times.
✗ Branch 1 not taken.
7426698 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17596 {
17597 for ( int32_t q = 0; q < 2; q++ )
17598 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17599 return qe_invalid;
17600 }
17601
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version >= 9)
17602
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17603 return qe_invalid;
17604
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version >= 22)
17605
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17606 return qe_invalid;
17607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 24)
17608 {
17609 if(!p_getc(&temp_trigger.triggeritem,f))
17610 return qe_invalid;
17611 if(!p_getc(&tempbyte, f))
17612 return qe_invalid;
17613 temp_trigger.trigtimer = tempbyte;
17614 }
17615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 25)
17616 if(!p_getc(&temp_trigger.trigsfx,f))
17617 return qe_invalid;
17618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 27)
17619 if(!p_igetl(&temp_trigger.trigchange,f))
17620 return qe_invalid;
17621
17622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 29)
17623 {
17624 if(!p_igetw(&temp_trigger.trigprox,f))
17625 return qe_invalid;
17626 if(!p_getc(&tempbyte,f))
17627 return qe_invalid;
17628 temp_trigger.trigctr = tempbyte;
17629 if(!p_igetl(&temp_trigger.trigctramnt,f))
17630 return qe_invalid;
17631 }
17632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 30)
17633 if(!p_getc(&temp_trigger.triglbeam,f))
17634 return qe_invalid;
17635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 31)
17636 {
17637 if(!p_getc(&temp_trigger.trigcschange,f))
17638 return qe_invalid;
17639 if(!p_igetw(&temp_trigger.spawnitem,f))
17640 return qe_invalid;
17641 if(!p_igetw(&temp_trigger.spawnenemy,f))
17642 return qe_invalid;
17643 if(!p_getc(&temp_trigger.exstate,f))
17644 return qe_invalid;
17645 if(!p_igetl(&temp_trigger.spawnip,f))
17646 return qe_invalid;
17647 if(!p_getc(&temp_trigger.trigcopycat,f))
17648 return qe_invalid;
17649 }
17650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7629666 times.
7629666 if(section_version >= 32)
17651 if(!p_getc(&temp_trigger.trigcooldown,f))
17652 return qe_invalid;
17653
17654
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=12) //combo label
17655 {
17656 char label[12];
17657 202968 label[11] = '\0';
17658
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17659
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17660 return qe_invalid;
17661
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17662 202968 }
17663
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=13) //attribytes[4]
17664
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17665
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17666 202968 return qe_invalid;
17667 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17668 * This fixes a poor implementation of a ->next flag bug thing.
17669 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17670 * there was a version bump a few weeks before a change that broke stuff.
17671 */
17672
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7629666 if (section_version >= 13 && section_version < 21)
17673 {
17674 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17675 }
17676 //combo scripts
17677
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=14)
17678 {
17679
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17680 return qe_invalid;
17681
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17682
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17683 return qe_invalid;
17684 202968 }
17685
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7426698 times.
7629666 if(section_version>=15)
17686 {
17687
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17688
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17689
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17690
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17691 202968 }
17692
2/2
✓ Branch 0 taken 7426698 times.
✓ Branch 1 taken 202968 times.
7629666 if(section_version>=17) //attribytes[4]
17693 {
17694
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17695
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17696 return qe_invalid;
17697
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17698
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17699 return qe_invalid;
17700 202968 }
17701
17702
2/2
✓ Branch 0 taken 7596756 times.
✓ Branch 1 taken 32910 times.
7629666 if(version < 0x193)
17703
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17704
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17705 32910 return qe_invalid;
17706 7629666 }
17707
17708 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17709
3/6
✓ Branch 0 taken 4741258 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4741258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7666530 if((version < 0x211)||((version == 0x211)&&(build<7)))
17710 {
17711
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17712 {
17713
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17714 {
17715 case 130:
17716 temp_combo.tile = 132;
17717 break;
17718
17719 case 131:
17720 temp_combo.tile = 133;
17721 break;
17722
17723 case 132:
17724 temp_combo.tile = 130;
17725 break;
17726
17727 case 133:
17728 temp_combo.tile = 131;
17729 break;
17730 }
17731 39936 }
17732 2925272 }
17733
17734
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 15)
17735 7463562 temp_combo.o_tile = temp_combo.tile;
17736
17737
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version<18) //upper bits for .walk
17738 7463562 temp_combo.walk |= 0xF0;
17739
17740
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 19)
17741
2/2
✓ Branch 0 taken 29854248 times.
✓ Branch 1 taken 7463562 times.
37317810 for(int32_t q = 0; q < 4; ++q)
17742 37317810 temp_combo.attributes[q] *= 10000L;
17743
17744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 23)
17745 {
17746
2/2
✓ Branch 0 taken 15359 times.
✓ Branch 1 taken 7651171 times.
7666530 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17747 {
17748 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17749 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17750 case cTRIGGERGENERIC: case cCSWITCH:
17751 15359 temp_trigger.triggerflags[0] |= combotriggerCMBTYPEFX;
17752 15359 }
17753 7666530 }
17754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 25)
17755 {
17756
2/2
✓ Branch 0 taken 27600 times.
✓ Branch 1 taken 7638930 times.
7666530 switch(temp_combo.type)
17757 {
17758 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27600 times.
27600 if(!(temp_combo.usrflags & cflag3))
17760 27600 temp_combo.attribytes[3] = WAV_DOOR;
17761 27600 temp_combo.usrflags &= ~cflag3;
17762 27600 break;
17763 }
17764 7666530 }
17765
17766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 26)
17767
2/2
✓ Branch 0 taken 7665388 times.
✓ Branch 1 taken 1142 times.
7667672 if(temp_combo.type == cARMOS)
17768
1/2
✓ Branch 0 taken 1142 times.
✗ Branch 1 not taken.
1142 if(temp_combo.usrflags & cflag1)
17769 temp_combo.usrflags |= cflag3;
17770
17771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 27)
17772 {
17773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(temp_trigger.triggerflags[0] & 0x00040000) //'next'
17774 temp_trigger.trigchange = 1;
17775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 else if(temp_trigger.triggerflags[0] & 0x00080000) //'prev'
17776 temp_trigger.trigchange = -1;
17777 7666530 else temp_trigger.trigchange = 0;
17778 7666530 temp_trigger.triggerflags[0] &= ~(0x00040000|0x00080000);
17779 7666530 }
17780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7666530 times.
7666530 if(section_version < 28)
17781 {
17782
2/2
✓ Branch 0 taken 15669 times.
✓ Branch 1 taken 7650861 times.
7666530 switch(temp_combo.type)
17783 {
17784 case cLOCKBLOCK: case cLOCKEDCHEST:
17785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15669 times.
15669 if(temp_combo.usrflags & cflag7)
17786 temp_combo.usrflags |= cflag8;
17787 15669 else temp_combo.usrflags &= ~cflag8;
17788 15669 temp_combo.usrflags &= ~cflag7;
17789 15669 break;
17790 }
17791
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 7665748 times.
7666530 switch(temp_combo.type)
17792 {
17793 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17794 782 temp_combo.attrishorts[2] = -1;
17795 782 temp_combo.usrflags |= cflag7;
17796 782 break;
17797 }
17798 7666530 }
17799
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7463562 times.
7666530 if(section_version < 20)
17800 {
17801 7463562 temp_combo.genflags = 0;
17802
2/2
✓ Branch 0 taken 144654 times.
✓ Branch 1 taken 7318908 times.
7463562 switch(temp_combo.type)
17803 {
17804 case cPUSH_WAIT: case cPUSH_HEAVY:
17805 case cPUSH_HW: case cL_STATUE:
17806 case cR_STATUE: case cPUSH_HEAVY2:
17807 case cPUSH_HW2: case cPOUND:
17808 case cC_STATUE: case cMIRROR:
17809 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17810 case cMAGICPRISM: case cMAGICPRISM4:
17811 case cMAGICSPONGE: case cEYEBALL_A:
17812 case cEYEBALL_B: case cEYEBALL_4:
17813 case cBUSH: case cFLOWERS:
17814 case cLOCKBLOCK: case cLOCKBLOCK2:
17815 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17816 case cCHEST: case cCHEST2:
17817 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17818 case cBOSSCHEST: case cBOSSCHEST2:
17819 case cBUSHNEXT: case cBUSHTOUCHY:
17820 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17821 case cSIGNPOST: case cCSWITCHBLOCK:
17822 case cTORCH: case cTRIGGERGENERIC:
17823
1/2
✓ Branch 0 taken 144654 times.
✗ Branch 1 not taken.
144654 if(temp_combo.usrflags & cflag16)
17824 {
17825 temp_combo.genflags |= cflag1;
17826 temp_combo.usrflags &= ~cflag16;
17827 }
17828 144654 break;
17829 }
17830 7463562 }
17831
17832
3/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15398 times.
✓ Branch 3 taken 7651132 times.
7666530 if(temp_trigger.is_blank())
17833 7651132 temp_combo.triggers.clear();
17834
17835 7666530 update_combo(temp_combo, section_version);
17836
17837
3/4
✓ Branch 0 taken 7666530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7651611 times.
✓ Branch 3 taken 14919 times.
7666530 if(i>=start_combo && !should_skip)
17838 {
17839
1/2
✓ Branch 0 taken 7651611 times.
✗ Branch 1 not taken.
7651611 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17840 {
17841 temp_combo.script = 0;
17842 for(int q = 0; q < 8; ++q)
17843 temp_combo.initd[q] = 0;
17844 }
17845
1/2
✓ Branch 0 taken 7651611 times.
✗ Branch 1 not taken.
7651611 combobuf[i] = temp_combo;
17846 7651611 }
17847 7666530 }
17848
17849
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 1 times.
293 if (should_skip)
17850 1 return 0;
17851
17852
5/6
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
292 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17853 {
17854
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17855 {
17856
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17857 {
17858 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17859 215 }
17860 1501440 }
17861 23 }
17862
17863 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17864
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
292 if(version == 0x210 && get_app_id() != App::zquest)
17865 {
17866
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17867
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17868 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17869 59 }
17870
17871
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 82 times.
292 if(section_version<7)
17872 {
17873
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17874 {
17875
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
17876 {
17877 case cSLASH:
17878 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
17879 853 break;
17880
17881 case cSLASHITEM:
17882 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17883 791 break;
17884
17885 case cBUSH:
17886 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
17887 603 break;
17888
17889 case cFLOWERS:
17890 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17891 174 break;
17892
17893 case cTALLGRASS:
17894 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17895 531 break;
17896
17897 case cSLASHNEXT:
17898 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17899 break;
17900
17901 case cSLASHNEXTITEM:
17902 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17903 break;
17904
17905 case cBUSHNEXT:
17906 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17907 break;
17908 }
17909 5352960 }
17910 82 }
17911
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 287 times.
292 if (section_version < 16)
17912 {
17913
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17914 {
17915
2/2
✓ Branch 0 taken 18706079 times.
✓ Branch 1 taken 29281 times.
18735360 if (combobuf[tmpcounter].type == cWATER)
17916 {
17917 29281 combobuf[tmpcounter].attributes[0] = 40000L;
17918 29281 }
17919 18735360 }
17920 287 }
17921
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17922 {
17923 3 combobuf[0].walk = 0xF0;
17924 3 combobuf[0].type = 0;
17925 3 combobuf[0].flag = 0;
17926 3 }
17927
17928 //Now for the new combo alias reset
17929
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 82 times.
292 if(section_version<2)
17930 {
17931
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17932 {
17933 671744 combo_aliases[j].width = 0;
17934 671744 combo_aliases[j].height = 0;
17935 671744 combo_aliases[j].layermask = 0;
17936
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
17937
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
17938 671744 }
17939 82 }
17940
17941
17942
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 setup_combo_animations();
17943
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 setup_combo_animations2();
17944 292 return 0;
17945 293 }
17946
17947 12054 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
17948 {
17949 byte tempbyte;
17950
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 4474 times.
12054 if(s_version >= 52)
17951
1/2
✓ Branch 0 taken 4474 times.
✗ Branch 1 not taken.
4474 if(!p_getcstr(&temp_trigger.label,f))
17952 return qe_invalid;
17953
17954 12054 int numtrigs = s_version < 36 ? 3 : 6;
17955
2/2
✓ Branch 0 taken 71466 times.
✓ Branch 1 taken 12054 times.
83520 for ( int32_t q = 0; q < numtrigs; q++ )
17956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71466 times.
71466 if(!p_igetl(&temp_trigger.triggerflags[q],f))
17957 return qe_invalid;
17958
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetl(&temp_trigger.triggerlevel,f))
17959 return qe_invalid;
17960
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.triggerbtn,f))
17961 return qe_invalid;
17962
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.triggeritem,f))
17963 return qe_invalid;
17964
2/2
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 9589 times.
12054 if(s_version >= 53)
17965 {
17966
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetw(&temp_trigger.trigtimer,f))
17967 return qe_invalid;
17968 2465 }
17969 else
17970 {
17971
1/2
✓ Branch 0 taken 9589 times.
✗ Branch 1 not taken.
9589 if(!p_getc(&tempbyte, f))
17972 return qe_invalid;
17973 9589 temp_trigger.trigtimer = tempbyte;
17974 }
17975
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigsfx,f))
17976 return qe_invalid;
17977
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetl(&temp_trigger.trigchange,f))
17978 return qe_invalid;
17979
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.trigprox,f))
17980 return qe_invalid;
17981
2/2
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 9589 times.
12054 if(s_version >= 53)
17982 {
17983
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetw(&temp_trigger.trigctr,f))
17984 return qe_invalid;
17985 2465 }
17986 else
17987 {
17988
1/2
✓ Branch 0 taken 9589 times.
✗ Branch 1 not taken.
9589 if(!p_getc(&tempbyte,f))
17989 return qe_invalid;
17990 9589 temp_trigger.trigctr = tempbyte;
17991 }
17992
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetl(&temp_trigger.trigctramnt,f))
17993 return qe_invalid;
17994
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.triglbeam,f))
17995 return qe_invalid;
17996
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigcschange,f))
17997 return qe_invalid;
17998
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.spawnitem,f))
17999 return qe_invalid;
18000
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.spawnenemy,f))
18001 return qe_invalid;
18002
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.exstate,f))
18003 return qe_invalid;
18004
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetl(&temp_trigger.spawnip,f))
18005 return qe_invalid;
18006
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigcopycat,f))
18007 return qe_invalid;
18008
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.trigcooldown,f))
18009 return qe_invalid;
18010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12054 times.
12054 if(s_version >= 35)
18011 {
18012
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.prompt_cid,f))
18013 return qe_invalid;
18014
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_getc(&temp_trigger.prompt_cs,f))
18015 return qe_invalid;
18016
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.prompt_x,f))
18017 return qe_invalid;
18018
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(!p_igetw(&temp_trigger.prompt_y,f))
18019 return qe_invalid;
18020 12054 }
18021
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11768 times.
12054 if(s_version >= 36)
18022 {
18023
1/2
✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
11768 if(!p_getc(&temp_trigger.trig_lstate,f))
18024 return qe_invalid;
18025
1/2
✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
11768 if(!p_getc(&temp_trigger.trig_gstate,f))
18026 return qe_invalid;
18027
1/2
✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
11768 if(!p_igetl(&temp_trigger.trig_statetime,f))
18028 return qe_invalid;
18029 11768 }
18030
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11768 times.
12054 if(s_version >= 37)
18031 {
18032
1/2
✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
11768 if(!p_igetw(&temp_trigger.trig_genscr,f))
18033 return qe_invalid;
18034 11768 }
18035
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 11620 times.
12054 if(s_version >= 38)
18036 {
18037
1/2
✓ Branch 0 taken 11620 times.
✗ Branch 1 not taken.
11620 if(!p_getc(&temp_trigger.trig_group,f))
18038 return qe_invalid;
18039
1/2
✓ Branch 0 taken 11620 times.
✗ Branch 1 not taken.
11620 if(!p_igetw(&temp_trigger.trig_group_val,f))
18040 return qe_invalid;
18041 11620 }
18042
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 11584 times.
12054 if(s_version >= 45)
18043 {
18044
1/2
✓ Branch 0 taken 11584 times.
✗ Branch 1 not taken.
11584 if(!p_getc(&temp_trigger.exdoor_dir,f))
18045 return qe_invalid;
18046
1/2
✓ Branch 0 taken 11584 times.
✗ Branch 1 not taken.
11584 if(!p_getc(&temp_trigger.exdoor_ind,f))
18047 return qe_invalid;
18048 11584 }
18049
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 4942 times.
12054 if(s_version >= 46)
18050 {
18051
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_getc(&temp_trigger.trig_levelitems,f))
18052 return qe_invalid;
18053
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18054 return qe_invalid;
18055
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(s_version >= 48)
18056 {
18057
2/2
✓ Branch 0 taken 14826 times.
✓ Branch 1 taken 4942 times.
19768 for(int q = 0; q < 3; ++q)
18058
1/2
✓ Branch 0 taken 14826 times.
✗ Branch 1 not taken.
14826 if(!p_igetw(&temp_trigger.trigtint[q],f))
18059 return qe_invalid;
18060 4942 }
18061 else
18062 {
18063 for(int q = 0; q < 3; ++q)
18064 if(!p_getc(&temp_trigger.trigtint[q],f))
18065 return qe_invalid;
18066 for(int q = 0; q < 3; ++q)
18067 {
18068 int v = temp_trigger.trigtint[q];
18069 int va = abs(v);
18070 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18071 }
18072 }
18073
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18074 return qe_invalid;
18075
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18076 return qe_invalid;
18077
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trigquaketime,f))
18078 return qe_invalid;
18079
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trigwavytime,f))
18080 return qe_invalid;
18081
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18082 return qe_invalid;
18083
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18084 return qe_invalid;
18085
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18086 return qe_invalid;
18087
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18088 return qe_invalid;
18089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4942 times.
4942 if(!p_getc(&temp_trigger.trig_pushtime,f))
18090 return qe_invalid;
18091 4942 }
18092
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 4942 times.
12054 if(s_version >= 47)
18093 {
18094
1/2
✓ Branch 0 taken 4942 times.
✗ Branch 1 not taken.
4942 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18095 return qe_invalid;
18096 4942 }
18097
2/2
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 9589 times.
12054 if(s_version >= 53)
18098 {
18099
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetl(&temp_trigger.req_level_state, f))
18100 return qe_invalid;
18101
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18102 return qe_invalid;
18103
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18104 return qe_invalid;
18105
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18106 return qe_invalid;
18107
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18108 return qe_invalid;
18109
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18110 return qe_invalid;
18111
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18112 return qe_invalid;
18113
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18114 return qe_invalid;
18115
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetzf(&temp_trigger.player_bounce, f))
18116 return qe_invalid;
18117
1/2
✓ Branch 0 taken 2465 times.
✗ Branch 1 not taken.
2465 if(!p_igetzf(&temp_trigger.req_player_z, f))
18118 return qe_invalid;
18119 2465 }
18120 else
18121 {
18122 9589 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18123 9589 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18124 }
18125 12054 return 0;
18126 12054 }
18127
18128 1353533 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18129 {
18130 byte combo_has_flags;
18131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1353533 times.
1353533 if(!p_getc(&combo_has_flags,f))
18132 return qe_invalid;
18133
18134 1353533 temp_combo.clear();
18135
2/2
✓ Branch 0 taken 713729 times.
✓ Branch 1 taken 639804 times.
1353533 if(combo_has_flags)
18136 {
18137
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 639747 times.
639804 if(combo_has_flags&CHAS_BASIC)
18138 {
18139
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_igetl(&temp_combo.tile,f))
18140 return qe_invalid;
18141 639747 temp_combo.o_tile = temp_combo.tile;
18142
18143
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.flip,f))
18144 return qe_invalid;
18145
18146
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.walk,f))
18147 return qe_invalid;
18148
18149
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.type,f))
18150 return qe_invalid;
18151
18152
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.flag,f))
18153 return qe_invalid;
18154
18155
1/2
✓ Branch 0 taken 639747 times.
✗ Branch 1 not taken.
639747 if(!p_getc(&temp_combo.csets,f))
18156 return qe_invalid;
18157 639747 }
18158
2/2
✓ Branch 0 taken 636980 times.
✓ Branch 1 taken 2824 times.
639804 if(combo_has_flags&CHAS_SCRIPT)
18159 {
18160
2/2
✓ Branch 0 taken 2794 times.
✓ Branch 1 taken 30 times.
2824 if (s_version>=41)
18161 {
18162 2794 p_getcstr(&temp_combo.label, f);
18163 2794 }
18164 else
18165 {
18166 char label[12];
18167 30 label[11] = '\0';
18168
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18169
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18170 return qe_invalid;
18171 30 temp_combo.label = label;
18172 }
18173
18174
1/2
✓ Branch 0 taken 2824 times.
✗ Branch 1 not taken.
2824 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18175 2824 auto initd_count = s_version >= 43 ? 8 : 2;
18176
2/2
✓ Branch 0 taken 22412 times.
✓ Branch 1 taken 2824 times.
25236 for ( int32_t q = 0; q < initd_count; q++ )
18177
1/2
✓ Branch 0 taken 22412 times.
✗ Branch 1 not taken.
22412 if(!p_igetl(&temp_combo.initd[q],f))
18178 return qe_invalid;
18179 2824 }
18180
2/2
✓ Branch 0 taken 517016 times.
✓ Branch 1 taken 122788 times.
639804 if(combo_has_flags&CHAS_ANIM)
18181 {
18182
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.frames,f))
18183 return qe_invalid;
18184
18185
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.speed,f))
18186 return qe_invalid;
18187
18188
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_igetw(&temp_combo.nextcombo,f))
18189 return qe_invalid;
18190
18191
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.nextcset,f))
18192 return qe_invalid;
18193
18194
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.skipanim,f))
18195 return qe_invalid;
18196
18197
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.skipanimy,f))
18198 return qe_invalid;
18199
18200
1/2
✓ Branch 0 taken 122788 times.
✗ Branch 1 not taken.
122788 if(!p_getc(&temp_combo.animflags,f))
18201 return qe_invalid;
18202 122788 }
18203
2/2
✓ Branch 0 taken 587386 times.
✓ Branch 1 taken 52418 times.
639804 if(combo_has_flags&CHAS_ATTRIB)
18204 {
18205
2/2
✓ Branch 0 taken 209672 times.
✓ Branch 1 taken 52418 times.
262090 for ( int32_t q = 0; q < 4; q++ )
18206
1/2
✓ Branch 0 taken 209672 times.
✗ Branch 1 not taken.
209672 if(!p_igetl(&temp_combo.attributes[q],f))
18207 return qe_invalid;
18208
2/2
✓ Branch 0 taken 419344 times.
✓ Branch 1 taken 52418 times.
471762 for ( int32_t q = 0; q < 8; q++ )
18209
1/2
✓ Branch 0 taken 419344 times.
✗ Branch 1 not taken.
419344 if(!p_getc(&temp_combo.attribytes[q],f))
18210 return qe_invalid;
18211
2/2
✓ Branch 0 taken 419344 times.
✓ Branch 1 taken 52418 times.
471762 for ( int32_t q = 0; q < 8; q++ )
18212
1/2
✓ Branch 0 taken 419344 times.
✗ Branch 1 not taken.
419344 if(!p_igetw(&temp_combo.attrishorts[q],f))
18213 return qe_invalid;
18214 52418 }
18215
2/2
✓ Branch 0 taken 628484 times.
✓ Branch 1 taken 11320 times.
639804 if(combo_has_flags&CHAS_FLAG)
18216 {
18217
1/2
✓ Branch 0 taken 11320 times.
✗ Branch 1 not taken.
11320 if(!p_igetl(&temp_combo.usrflags,f))
18218 return qe_invalid;
18219
1/2
✓ Branch 0 taken 11320 times.
✗ Branch 1 not taken.
11320 if(!p_igetw(&temp_combo.genflags,f))
18220 return qe_invalid;
18221 11320 }
18222
2/2
✓ Branch 0 taken 627750 times.
✓ Branch 1 taken 12054 times.
639804 if(combo_has_flags&CHAS_TRIG)
18223 {
18224 12054 byte count = 1;
18225
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 4474 times.
12054 if(s_version >= 52)
18226
1/2
✓ Branch 0 taken 4474 times.
✗ Branch 1 not taken.
4474 if(!p_getc(&count, f))
18227 return qe_invalid;
18228
18229
2/2
✓ Branch 0 taken 12054 times.
✓ Branch 1 taken 12054 times.
24108 for(byte q = 0; q < count; ++q)
18230 {
18231 12054 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18232 12054 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18233
1/2
✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
12054 if(ret)
18234 return ret;
18235 12054 }
18236
18237
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 4474 times.
12054 if(s_version < 52)
18238 {
18239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7580 times.
7580 if(!temp_combo.triggers.empty())
18240 7580 temp_combo.only_gentrig = (temp_combo.triggers[0].triggerflags[0] & combotriggerONLYGENTRIG) ? 1 : 0;
18241 7580 }
18242
1/2
✓ Branch 0 taken 4474 times.
✗ Branch 1 not taken.
4474 else if(!p_getc(&temp_combo.only_gentrig,f))
18243 return qe_invalid;
18244 12054 }
18245
2/2
✓ Branch 0 taken 639291 times.
✓ Branch 1 taken 513 times.
639804 if(combo_has_flags&CHAS_LIFT)
18246 {
18247
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_igetw(&temp_combo.liftcmb,f))
18248 return qe_invalid;
18249
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftcs,f))
18250 return qe_invalid;
18251
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_igetw(&temp_combo.liftundercmb,f))
18252 return qe_invalid;
18253
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftundercs,f))
18254 return qe_invalid;
18255
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftdmg,f))
18256 return qe_invalid;
18257
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftlvl,f))
18258 return qe_invalid;
18259
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftitm,f))
18260 return qe_invalid;
18261
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftflags,f))
18262 return qe_invalid;
18263
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftgfx,f))
18264 return qe_invalid;
18265
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftsprite,f))
18266 return qe_invalid;
18267
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftsfx,f))
18268 return qe_invalid;
18269
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18270 return qe_invalid;
18271
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.liftbreaksfx,f))
18272 return qe_invalid;
18273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 513 times.
513 if(s_version >= 34)
18274 {
18275
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.lifthei,f))
18276 return qe_invalid;
18277
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_combo.lifttime,f))
18278 return qe_invalid;
18279 513 }
18280
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 499 times.
513 if(s_version >= 39)
18281 {
18282
1/2
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
499 if(!p_getc(&temp_combo.lift_parent_item,f))
18283 return qe_invalid;
18284 499 }
18285
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 396 times.
513 if(s_version >= 51)
18286 {
18287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 if(!p_getc(&temp_combo.liftlightrad,f))
18288 return qe_invalid;
18289
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(!p_getc(&temp_combo.liftlightshape,f))
18290 return qe_invalid;
18291 396 }
18292 513 }
18293
2/2
✓ Branch 0 taken 609474 times.
✓ Branch 1 taken 30330 times.
639804 if(combo_has_flags&CHAS_GENERAL)
18294 {
18295
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.speed_mult,f))
18296 return qe_invalid;
18297
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.speed_div,f))
18298 return qe_invalid;
18299
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_igetzf(&temp_combo.speed_add,f))
18300 return qe_invalid;
18301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30330 times.
30330 if(s_version >= 42)
18302 {
18303
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_appear,f))
18304 return qe_invalid;
18305
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_disappear,f))
18306 return qe_invalid;
18307
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_loop,f))
18308 return qe_invalid;
18309
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_walking,f))
18310 return qe_invalid;
18311
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_standing,f))
18312 return qe_invalid;
18313
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.spr_appear,f))
18314 return qe_invalid;
18315
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.spr_disappear,f))
18316 return qe_invalid;
18317
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.spr_walking,f))
18318 return qe_invalid;
18319
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.spr_standing,f))
18320 return qe_invalid;
18321 30330 }
18322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30330 times.
30330 if(s_version >= 44)
18323 {
18324
1/2
✓ Branch 0 taken 30330 times.
✗ Branch 1 not taken.
30330 if(!p_getc(&temp_combo.sfx_tap,f))
18325 return qe_invalid;
18326 30330 }
18327
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 29964 times.
30330 if(s_version >= 49)
18328 {
18329
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.sfx_landing,f))
18330 return qe_invalid;
18331 29964 }
18332
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 29964 times.
30330 if(s_version >= 50)
18333 {
18334
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.spr_falling,f))
18335 return qe_invalid;
18336
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.spr_drowning,f))
18337 return qe_invalid;
18338
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18339 return qe_invalid;
18340
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.sfx_falling,f))
18341 return qe_invalid;
18342
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.sfx_drowning,f))
18343 return qe_invalid;
18344
1/2
✓ Branch 0 taken 29964 times.
✗ Branch 1 not taken.
29964 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18345 return qe_invalid;
18346 29964 }
18347 30330 }
18348 639804 }
18349 1353533 update_combo(temp_combo, s_version);
18350 1353533 return 0;
18351 1353533 }
18352
18353 470 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18354 {
18355
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18356
18357 470 word section_version=0;
18358 470 word combos_used=0;
18359 int32_t dummy;
18360 byte padding;
18361 470 newcombo temp_combo;
18362
18363
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 469 times.
470 if (!should_skip)
18364 {
18365
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 reset_all_combo_animations();
18366
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 init_combo_classes();
18367
18368
2/2
✓ Branch 0 taken 30616320 times.
✓ Branch 1 taken 469 times.
30616789 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18369
1/2
✓ Branch 0 taken 30616320 times.
✗ Branch 1 not taken.
30616320 combobuf[q].clear();
18370 469 }
18371
18372
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 24 times.
470 if(version > 0x192) //Version info
18373 {
18374
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&section_version,f))
18375 {
18376 return qe_invalid;
18377 }
18378 446 FFCore.quest_format[vCombos] = section_version;
18379
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!read_deprecated_section_cversion(f))
18380 {
18381 return qe_invalid;
18382 }
18383
18384 //section size
18385
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy,f))
18386 {
18387 return qe_invalid;
18388 }
18389 446 }
18390
18391
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 293 times.
470 if(section_version > 32) //Cleanup time!
18392 {
18393
2/4
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
177 if(!p_igetw(&combos_used,f))
18394 {
18395 return qe_invalid;
18396 }
18397
2/2
✓ Branch 0 taken 1353533 times.
✓ Branch 1 taken 177 times.
1353710 for(int32_t i=0; i<combos_used; i++)
18398 {
18399
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 auto ret = readcombo_loop(f,section_version,temp_combo);
18400
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 if(ret) return ret;
18401
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 if(i>=start_combo)
18402 {
18403
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18404 {
18405 temp_combo.script = 0;
18406 for(int q = 0; q < 8; ++q)
18407 temp_combo.initd[q] = 0;
18408 }
18409
1/2
✓ Branch 0 taken 1353533 times.
✗ Branch 1 not taken.
1353533 combobuf[i] = temp_combo;
18410 1353533 }
18411 1353533 }
18412 177 }
18413 else //Call the old function for all old versions
18414 {
18415
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if(ret) return ret; //error, end read
18417 }
18418
18419
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 1 times.
470 if (should_skip)
18420 1 return 0;
18421
18422
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 168 times.
469 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18423 {
18424 168 combobuf[0].walk = 0xF0;
18425 168 combobuf[0].type = 0;
18426 168 combobuf[0].flag = 0;
18427 168 }
18428
18429
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 setup_combo_animations();
18430
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 setup_combo_animations2();
18431 469 return 0;
18432 470 }
18433
18434 387 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18435 {
18436 //these are here to bypass compiler warnings about unused arguments
18437 387 Header=Header;
18438 387 version=version;
18439 387 build=build;
18440
18441 int32_t dummy;
18442 387 word sversion=0, c_sversion;
18443
18444 //section version info
18445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(!p_igetw(&sversion,f))
18446 {
18447 return qe_invalid;
18448 }
18449
18450 387 FFCore.quest_format[vComboAliases] = sversion;
18451
18452
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&c_sversion,f))
18453 {
18454 return qe_invalid;
18455 }
18456
18457 //section size
18458
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy,f))
18459 {
18460 return qe_invalid;
18461 }
18462
18463 387 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18464
18465
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 205 times.
387 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18466 {
18467 205 max_num_combo_aliases = MAX250COMBOALIASES;
18468 205 }
18469
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18470 {
18471 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18472 }
18473
18474
2/2
✓ Branch 0 taken 1910784 times.
✓ Branch 1 taken 387 times.
1911171 for(int32_t j=0; j<max_num_combo_aliases; j++)
18475 {
18476 byte width,height,mask,tempcset;
18477 int32_t count;
18478 word tempword;
18479 byte tempbyte;
18480
18481
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_igetw(&tempword,f))
18482 {
18483 return qe_invalid;
18484 }
18485
18486 1910784 combo_aliases[j].combo = tempword;
18487
18488
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_getc(&tempbyte,f))
18489 {
18490 return qe_invalid;
18491 }
18492
18493 1910784 combo_aliases[j].cset = tempbyte;
18494
18495
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_getc(&width,f))
18496 {
18497 return qe_invalid;
18498 }
18499
18500
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_getc(&height,f))
18501 {
18502 return qe_invalid;
18503 }
18504
18505
1/2
✓ Branch 0 taken 1910784 times.
✗ Branch 1 not taken.
1910784 if(!p_getc(&mask,f))
18506 {
18507 return qe_invalid;
18508 }
18509
18510 1910784 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18511
18512 1910784 combo_aliases[j].width = width;
18513 1910784 combo_aliases[j].height = height;
18514 1910784 combo_aliases[j].layermask = mask;
18515 1910784 combo_aliases[j].combos.clear();
18516 1910784 combo_aliases[j].csets.clear();
18517
18518
2/2
✓ Branch 0 taken 1961348 times.
✓ Branch 1 taken 1910784 times.
3872132 for(int32_t k=0; k<count; k++)
18519 {
18520
1/2
✓ Branch 0 taken 1961348 times.
✗ Branch 1 not taken.
1961348 if(!p_igetw(&tempword,f))
18521 {
18522 return qe_invalid;
18523 }
18524
18525 1961348 combo_aliases[j].combos[k] = tempword;
18526 1961348 }
18527
18528
2/2
✓ Branch 0 taken 1961348 times.
✓ Branch 1 taken 1910784 times.
3872132 for(int32_t k=0; k<count; k++)
18529 {
18530
1/2
✓ Branch 0 taken 1961348 times.
✗ Branch 1 not taken.
1961348 if(!p_getc(&tempcset,f))
18531 {
18532 return qe_invalid;
18533 }
18534
18535 1961348 combo_aliases[j].csets[k] = tempcset;
18536 1961348 }
18537 1910784 }
18538
18539 //Combo pools!
18540 387 word num_combo_pools = 0;
18541
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 177 times.
387 if(sversion >= 4)
18542 {
18543
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_igetw(&num_combo_pools,f))
18544 {
18545 return qe_invalid;
18546 }
18547 177 }
18548
18549
2/2
✓ Branch 0 taken 3170304 times.
✓ Branch 1 taken 387 times.
3170691 for(combo_pool& pool : combo_pools)
18550 {
18551 3170304 pool.clear();
18552 }
18553
18554 387 combo_pool temp_cpool;
18555
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 387 times.
831 for(word cp = 0; cp < num_combo_pools; ++cp)
18556 {
18557 444 int32_t num_combos_in_pool = 0;
18558
2/4
✓ Branch 0 taken 444 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 444 times.
✗ Branch 3 not taken.
444 if(!p_igetl(&num_combos_in_pool,f))
18559 {
18560 return qe_invalid;
18561 }
18562
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 96 times.
444 if(num_combos_in_pool < 1) continue; //nothing to read
18563
18564
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 temp_cpool.clear();
18565
18566 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18567
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 1576 times.
1924 for(auto q = 0; q < num_combos_in_pool; ++q)
18568 {
18569
2/4
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1576 times.
✗ Branch 3 not taken.
1576 if(!p_igetl(&cp_cid,f))
18570 {
18571 return qe_invalid;
18572 }
18573
2/4
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1576 times.
✗ Branch 3 not taken.
1576 if(!p_getc(&cp_cs,f))
18574 {
18575 return qe_invalid;
18576 }
18577
2/4
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1576 times.
✗ Branch 3 not taken.
1576 if(!p_igetw(&cp_quant,f))
18578 {
18579 return qe_invalid;
18580 }
18581
1/2
✓ Branch 0 taken 1576 times.
✗ Branch 1 not taken.
1576 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18582 1576 }
18583
18584
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 combo_pools[cp] = temp_cpool;
18585 348 }
18586
18587 //Autocombos!
18588 387 word num_combo_autos = 0;
18589
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 222 times.
387 if (sversion >= 5)
18590 {
18591
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if (!p_igetw(&num_combo_autos, f))
18592 {
18593 return qe_invalid;
18594 }
18595 165 }
18596
18597
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 3170304 times.
3170691 for (combo_auto& cauto : combo_autos)
18598 {
18599
1/2
✓ Branch 0 taken 3170304 times.
✗ Branch 1 not taken.
3170304 cauto.clear(true);
18600 }
18601
18602
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 combo_auto temp_cauto;
18603
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 387 times.
462 for (word ca = 0; ca < num_combo_autos; ++ca)
18604 {
18605 byte type;
18606 int32_t display_cid, erase_cid;
18607 byte flags, arg;
18608
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&type, f))
18609 {
18610 return qe_invalid;
18611 }
18612
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&display_cid, f))
18613 {
18614 return qe_invalid;
18615 }
18616
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&erase_cid, f))
18617 {
18618 return qe_invalid;
18619 }
18620
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&flags, f))
18621 {
18622 return qe_invalid;
18623 }
18624
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&arg, f))
18625 {
18626 return qe_invalid;
18627 }
18628 75 int32_t num_combos_in_cauto = 0;
18629
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&num_combos_in_cauto, f))
18630 {
18631 return qe_invalid;
18632 }
18633
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if (num_combos_in_cauto < 1) continue; //nothing to read
18634
18635
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.clear();
18636
18637
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setType(type);
18638
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setDisplay(display_cid);
18639
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setEraseCombo(erase_cid);
18640
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setFlags(flags);
18641
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setArg(arg);
18642
18643 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18644
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 930 times.
1005 for (auto q = 0; q < num_combos_in_cauto; ++q)
18645 {
18646
2/4
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
930 if (!p_getc(&ca_ctype, f))
18647 {
18648 return qe_invalid;
18649 }
18650
2/4
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
930 if (!p_igetl(&ca_cid, f))
18651 {
18652 return qe_invalid;
18653 }
18654
1/2
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
930 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18655 930 }
18656
18657
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 combo_autos[ca] = temp_cauto;
18658 75 }
18659
18660 387 return 0;
18661 387 }
18662
18663 787 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18664 {
18665
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18666
18667 //these are here to bypass compiler warnings about unused arguments
18668 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18669 //Capitalized cause it'll save you a headache. -Deedee
18670 787 start_cset=start_cset;
18671 787 max_csets=max_csets;
18672 787 word s_version=0;
18673
18674 miscQdata temp_misc;
18675 787 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18676
18677 byte temp_colordata[48];
18678 char temp_palname[PALNAMESIZE+1];
18679
18680 int32_t dummy;
18681 word palcycles;
18682
18683
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(version > 0x192)
18684 {
18685 //section version info
18686
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&s_version,f))
18687 {
18688 return qe_invalid;
18689 }
18690
18691 763 FFCore.quest_format[vCSets] = s_version;
18692
18693
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&dummy,f))
18694 {
18695 return qe_invalid;
18696 }
18697
18698 //section size
18699
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetl(&dummy,f))
18700 {
18701 return qe_invalid;
18702 }
18703 763 }
18704
2/2
✓ Branch 0 taken 605 times.
✓ Branch 1 taken 182 times.
787 if (s_version < 5)
18705 {
18706
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 587 times.
✓ Branch 2 taken 581 times.
✓ Branch 3 taken 6 times.
605 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18707
18708 //finally... section data
18709 605 int32_t q = 0;
18710 605 int32_t p = -15;
18711
2/2
✓ Branch 0 taken 145200 times.
✓ Branch 1 taken 605 times.
145805 for(int32_t i=0; i<oldpdTOTAL; ++i)
18712 {
18713 145200 memset(temp_colordata, 0, 48);
18714
18715
1/2
✓ Branch 0 taken 145200 times.
✗ Branch 1 not taken.
145200 if(!pfread(temp_colordata,48,f))
18716 {
18717 return qe_invalid;
18718 }
18719
18720
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 144960 times.
145200 if (should_skip)
18721 240 continue;
18722
18723 144960 memcpy(&colordata[q*48], temp_colordata, 48);
18724
18725 144960 ++q;
18726
8/8
✓ Branch 0 taken 135296 times.
✓ Branch 1 taken 9664 times.
✓ Branch 2 taken 10268 times.
✓ Branch 3 taken 125028 times.
✓ Branch 4 taken 1208 times.
✓ Branch 5 taken 9060 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1172 times.
144960 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18727 {
18728
1/2
✓ Branch 0 taken 10232 times.
✗ Branch 1 not taken.
10232 if (s_version < 5) //Bumping up the size of level palettes
18729 {
18730 10232 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18731 10232 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18732 10232 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18733 10232 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18734 10232 q+=4;
18735 10232 }
18736 else
18737 {
18738 for(int m = 0; m < 4; ++m)
18739 {
18740 memset(temp_colordata, 0, 48);
18741 if(!pfread(temp_colordata,48,f))
18742 {
18743 return qe_invalid;
18744 }
18745 memcpy(&colordata[q*48], temp_colordata, 48);
18746 ++q;
18747 }
18748 }
18749 10232 }
18750 144960 ++p;
18751 144960 }
18752
18753
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 587 times.
605 if(RealOldVerion)
18754 {
18755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18756 {
18757 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18758 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18759 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18760 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18761 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18762 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18763 18 }
18764 18 }
18765 else
18766 {
18767 587 memset(temp_colordata, 0, 48);
18768
18769
2/2
✓ Branch 0 taken 1839071 times.
✓ Branch 1 taken 587 times.
1839658 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18770 {
18771
1/2
✓ Branch 0 taken 1839071 times.
✗ Branch 1 not taken.
1839071 if(!pfread(temp_colordata,48,f))
18772 {
18773 return qe_invalid;
18774 }
18775
18776
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1835938 times.
1839071 if (should_skip)
18777 3133 continue;
18778
18779 1835938 memcpy(&colordata[q*48], temp_colordata, 48);
18780
18781 1835938 ++q;
18782
7/8
✓ Branch 0 taken 1835938 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141226 times.
✓ Branch 3 taken 1694712 times.
✓ Branch 4 taken 1172 times.
✓ Branch 5 taken 140054 times.
✓ Branch 6 taken 1044 times.
✓ Branch 7 taken 128 times.
1835938 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18783 {
18784
1/2
✓ Branch 0 taken 141098 times.
✗ Branch 1 not taken.
141098 if (s_version < 5) //Bumping up the size of level palettes
18785 {
18786 141098 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18787 141098 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18788 141098 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18789 141098 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18790 141098 q+=4;
18791 141098 }
18792 else
18793 {
18794 for(int m = 0; m < 4; ++m)
18795 {
18796 memset(temp_colordata, 0, 48);
18797 if(!pfread(temp_colordata,48,f))
18798 {
18799 return qe_invalid;
18800 }
18801 memcpy(&colordata[q*48], temp_colordata, 48);
18802 ++q;
18803 }
18804 }
18805 141098 }
18806 1835938 ++p;
18807 1835938 }
18808
18809
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 522 times.
587 if(s_version < 4)
18810 {
18811
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
18812 {
18813 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18814 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18815 64 }
18816 65 }
18817 else
18818 {
18819
2/2
✓ Branch 0 taken 1737216 times.
✓ Branch 1 taken 522 times.
1737738 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18820 {
18821
1/2
✓ Branch 0 taken 1737216 times.
✗ Branch 1 not taken.
1737216 if(!pfread(temp_colordata,48,f))
18822 {
18823 return qe_invalid;
18824 }
18825
18826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1737216 times.
1737216 if (should_skip)
18827 continue;
18828
18829 1737216 memcpy(&colordata[q*48], temp_colordata, 48);
18830 1737216 ++q;
18831
5/6
✓ Branch 0 taken 1737216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133632 times.
✓ Branch 3 taken 1603584 times.
✓ Branch 4 taken 1044 times.
✓ Branch 5 taken 132588 times.
1737216 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18832 {
18833
1/2
✓ Branch 0 taken 132588 times.
✗ Branch 1 not taken.
132588 if (s_version < 5) //Bumping up the size of level palettes
18834 {
18835 132588 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18836 132588 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18837 132588 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18838 132588 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18839 132588 q+=4;
18840 132588 }
18841 else
18842 {
18843 for(int m = 0; m < 4; ++m)
18844 {
18845 memset(temp_colordata, 0, 48);
18846 if(!pfread(temp_colordata,48,f))
18847 {
18848 return qe_invalid;
18849 }
18850 memcpy(&colordata[q*48], temp_colordata, 48);
18851 ++q;
18852 }
18853 }
18854 132588 }
18855 1737216 ++p;
18856 1737216 }
18857
18858 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18859 }
18860 }
18861 605 }
18862 else
18863 {
18864
2/2
✓ Branch 0 taken 1592318 times.
✓ Branch 1 taken 182 times.
1592500 for(int32_t i=0; i<pdTOTAL255; ++i)
18865 {
18866 1592318 memset(temp_colordata, 0, 48);
18867
18868
1/2
✓ Branch 0 taken 1592318 times.
✗ Branch 1 not taken.
1592318 if(!pfread(temp_colordata,48,f))
18869 {
18870 return qe_invalid;
18871 }
18872
18873 1592318 memcpy(&colordata[i*48], temp_colordata, 48);
18874 1592318 }
18875 }
18876
18877
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 137 times.
✓ Branch 3 taken 649 times.
787 if (!should_skip && s_version < 6)
18878 {
18879
2/2
✓ Branch 0 taken 272548848 times.
✓ Branch 1 taken 649 times.
272549497 for (int i = 0; i < psTOTAL255; i++)
18880 {
18881 272548848 colordata[i] = _rgb_scale_6[colordata[i]];
18882 272548848 }
18883 649 }
18884
18885
5/6
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 763 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
787 if((version < 0x192)||((version == 0x192)&&(build<76)))
18886 {
18887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18888 18 init_palnames();
18889 18 }
18890 else
18891 {
18892 769 int32_t palnamestoread = 0;
18893
18894
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 704 times.
769 if(s_version < 3)
18895 65 palnamestoread = OLDMAXLEVELS;
18896 else
18897 704 palnamestoread = 512;
18898
18899
2/2
✓ Branch 0 taken 377088 times.
✓ Branch 1 taken 769 times.
377857 for(int32_t i=0; i<palnamestoread; ++i)
18900 {
18901
1/2
✓ Branch 0 taken 377088 times.
✗ Branch 1 not taken.
377088 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18902 {
18903 return qe_invalid;
18904 }
18905
18906
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 376832 times.
377088 if (!should_skip)
18907 376832 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18908 377088 }
18909
18910
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 768 times.
769 if (should_skip)
18911 1 return 0;
18912
18913
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 768 times.
17152 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18914 {
18915 16384 memset(palnames[i], 0, PALNAMESIZE);
18916 16384 }
18917 }
18918
18919
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 763 times.
786 if(version > 0x192)
18920 {
18921
2/2
✓ Branch 0 taken 195328 times.
✓ Branch 1 taken 763 times.
196091 for(int32_t i=0; i<256; i++)
18922 {
18923
2/2
✓ Branch 0 taken 585984 times.
✓ Branch 1 taken 195328 times.
781312 for(int32_t j=0; j<3; j++)
18924 {
18925 585984 temp_misc.cycles[i][j].first=0;
18926 585984 temp_misc.cycles[i][j].count=0;
18927 585984 temp_misc.cycles[i][j].speed=0;
18928 585984 }
18929 195328 }
18930
18931
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&palcycles,f))
18932 {
18933 return qe_invalid;
18934 }
18935
18936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if (palcycles > NUM_PAL_CYCLES)
18937 {
18938 return qe_invalid;
18939 }
18940
18941
2/2
✓ Branch 0 taken 22139 times.
✓ Branch 1 taken 763 times.
22902 for(int32_t i=0; i<palcycles; i++)
18942 {
18943
2/2
✓ Branch 0 taken 66417 times.
✓ Branch 1 taken 22139 times.
88556 for(int32_t j=0; j<3; j++)
18944 {
18945
1/2
✓ Branch 0 taken 66417 times.
✗ Branch 1 not taken.
66417 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18946 {
18947 return qe_invalid;
18948 }
18949 66417 }
18950
18951
2/2
✓ Branch 0 taken 66417 times.
✓ Branch 1 taken 22139 times.
88556 for(int32_t j=0; j<3; j++)
18952 {
18953
1/2
✓ Branch 0 taken 66417 times.
✗ Branch 1 not taken.
66417 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18954 {
18955 return qe_invalid;
18956 }
18957 66417 }
18958
18959
2/2
✓ Branch 0 taken 66417 times.
✓ Branch 1 taken 22139 times.
88556 for(int32_t j=0; j<3; j++)
18960 {
18961
1/2
✓ Branch 0 taken 66417 times.
✗ Branch 1 not taken.
66417 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18962 {
18963 return qe_invalid;
18964 }
18965 66417 }
18966 22139 }
18967
18968 763 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18969 763 }
18970
18971 786 return 0;
18972 787 }
18973
18974 787 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18975 {
18976
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18977
18978 787 int32_t tiles_used=0;
18979 787 word section_version = 0;
18980 787 int32_t section_size= 0;
18981 787 byte *temp_tile = new byte[tilesize(tf32Bit)];
18982
18983 //Tile Expansion
18984 //if ( version >= 0x254 && build >= 41 )
18985
4/4
✓ Branch 0 taken 605 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 599 times.
787 if (version < 0x254 && build < 41)
18986 {
18987 599 max_tiles = ZC250MAXTILES;
18988 599 }
18989
18990
18991
2/6
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 787 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
787 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18992 {
18993 if(!init_tiles_for_190(true, Header))
18994 {
18995 al_trace("Unable to initialize tiles\n");
18996 }
18997
18998 delete[] temp_tile;
18999 temp_tile=NULL;
19000 return 0;
19001 }
19002 else
19003 {
19004
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 763 times.
787 if(version > 0x192)
19005 {
19006 //section version info
19007
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetw(&section_version,f))
19008 {
19009 delete[] temp_tile;
19010 return qe_invalid;
19011 }
19012
19013 763 FFCore.quest_format[vTiles] = section_version;
19014
19015
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!read_deprecated_section_cversion(f))
19016 {
19017 delete[] temp_tile;
19018 return qe_invalid;
19019 }
19020
19021 //section size
19022
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if(!p_igetl(&section_size,f))
19023 {
19024 delete[] temp_tile;
19025 return qe_invalid;
19026 }
19027 763 }
19028
19029 //if ( build < 41 )
19030 //{
19031 // tiles_used = ZC250MAXTILES;
19032 //}
19033
19034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if(version < 0x174)
19035 {
19036 tiles_used=TILES_PER_PAGE*4;
19037 } //no expanded tile space
19038
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 769 times.
787 else if(version < 0x191)
19039 {
19040 18 tiles_used=OLDMAXTILES;
19041 18 }
19042 else
19043 {
19044 //finally... section data
19045
3/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 587 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
769 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19046 {
19047
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!p_igetl(&tiles_used,f))
19048 {
19049 delete[] temp_tile;
19050 return qe_invalid;
19051 }
19052 182 }
19053 else
19054 {
19055
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(!p_igetw(&tiles_used,f))
19056 {
19057 delete[] temp_tile;
19058 return qe_invalid;
19059 }
19060 }
19061 }
19062
19063
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 tiles_used=zc_min(tiles_used, max_tiles);
19064
19065 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19066 //if ( version < 0x254 && build < 41 )
19067
3/6
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
787 if ( version < 0x254 || (version == 0x254 && build < 41) )
19068 //if ( build < 41 )
19069 {
19070
1/2
✓ Branch 0 taken 605 times.
✗ Branch 1 not taken.
605 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19071 605 }
19072 else //2.55
19073 {
19074
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19075 }
19076
19077 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19078
19079
19080
2/2
✓ Branch 0 taken 18117181 times.
✓ Branch 1 taken 787 times.
18117968 for(int32_t i=0; i<tiles_used; ++i)
19081 {
19082 18117181 byte format=tf4Bit;
19083 18117181 memset(temp_tile, 0, tilesize(tf32Bit));
19084
19085
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 15131725 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18117181 if((version>0x211)||((version==0x211)&&(build>4)))
19086 {
19087
1/2
✓ Branch 0 taken 15131725 times.
✗ Branch 1 not taken.
15131725 if(!p_getc(&format,f))
19088 {
19089 delete[] temp_tile;
19090 return qe_invalid;
19091 }
19092 15131725 }
19093
4/4
✓ Branch 0 taken 6930112 times.
✓ Branch 1 taken 11187069 times.
✓ Branch 2 taken 3173335 times.
✓ Branch 3 taken 3756777 times.
18117181 if(section_version > 2 && !format)
19094 {
19095 3756777 reset_tile(buf,start_tile+i,tf4Bit);
19096 3756777 continue;
19097 }
19098
19099
2/2
✓ Branch 0 taken 13870901 times.
✓ Branch 1 taken 489503 times.
14360404 int size = format == tf4Bit ? 128 : tilesize(format);
19100
1/2
✓ Branch 0 taken 14360404 times.
✗ Branch 1 not taken.
14360404 if(!pfread(temp_tile,size,f))
19101 {
19102 delete[] temp_tile;
19103 return qe_invalid;
19104 }
19105
19106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14360404 times.
14360404 if (should_skip)
19107 continue;
19108
19109 14360404 buf[start_tile+i].format=format;
19110
19111
2/2
✓ Branch 0 taken 14156519 times.
✓ Branch 1 taken 203885 times.
14360404 if(buf[start_tile+i].data)
19112 {
19113 14156519 free(buf[start_tile+i].data);
19114 14156519 buf[start_tile+i].data=NULL;
19115 14156519 }
19116
19117 14360404 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19118
19119
2/2
✓ Branch 0 taken 13870901 times.
✓ Branch 1 taken 489503 times.
14360404 if (format == tf4Bit)
19120 {
19121 byte temp[256];
19122 13870901 byte *si = temp_tile + 128;
19123 13870901 byte *di = temp + 256;
19124
19125
2/2
✓ Branch 0 taken 1775475328 times.
✓ Branch 1 taken 13870901 times.
1789346229 for(int i=127; i>=0; --i)
19126 {
19127 1775475328 (*(--di)) = (*(--si)) >> 4;
19128 1775475328 (*(--di)) = (*si) & 15;
19129 1775475328 }
19130
19131 13870901 memcpy(buf[start_tile+i].data,temp,256);
19132 13870901 }
19133 else
19134 {
19135 489503 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19136 }
19137 14360404 }
19138 }
19139
19140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if (should_skip)
19141 return 0;
19142
19143
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 605 times.
787 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19144 {
19145
2/2
✓ Branch 0 taken 90132900 times.
✓ Branch 1 taken 605 times.
90133505 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19146 {
19147
19148 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19149 90132900 reset_tile(buf,q,tf4Bit);
19150
19151
19152 /*
19153
19154 byte tempbyte;
19155 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19156 {
19157 tempbyte=buf[ZC250MAXTILES-1].data[i];
19158 buf[q].data[i] = tempbyte;
19159 }
19160 //int32_t temp = tempbyte=buf[130].data[i];
19161 //buf[q].data = buf[ZC250MAXTILES-1].data;
19162 */
19163 //reset_tile(buf,q,tf4Bit);
19164 90132900 }
19165
19166 605 }
19167
19168
4/6
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 605 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 182 times.
787 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19169 {
19170
2/2
✓ Branch 0 taken 29920127 times.
✓ Branch 1 taken 605 times.
29920732 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19171 {
19172 29920127 reset_tile(buf,i,tf4Bit);
19173 29920127 }
19174 605 }
19175 else
19176 {
19177
2/2
✓ Branch 0 taken 31535172 times.
✓ Branch 1 taken 182 times.
31535354 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19178 {
19179 31535172 reset_tile(buf,i,tf4Bit);
19180 31535172 }
19181 }
19182
19183
5/6
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 763 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
787 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19184 {
19185
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19186 {
19187 byte tempbyte;
19188 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19189
19190
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19191 {
19192 1536 tempbyte=buf[23].data[i];
19193 1536 buf[23].data[i]=buf[24].data[i];
19194 1536 buf[24].data[i]=buf[25].data[i];
19195 1536 buf[25].data[i]=buf[26].data[i];
19196 1536 buf[26].data[i]=tempbyte;
19197 1536 }
19198 //swim tiles are out of order, too, but nobody cared? -Z
19199
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19200 {
19201 1536 tempbyte=buf[floattile+11].data[i];
19202 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19203 1536 buf[floattile+12].data[i]=tempbyte;
19204 1536 }
19205 6 }
19206 24 }
19207
19208
3/6
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
787 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19209 {
19210
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19211 {
19212 byte tempbyte;
19213
19214
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19215 {
19216 5632 tempbyte=buf[130].data[i];
19217 5632 buf[130].data[i]=buf[132].data[i];
19218 5632 buf[132].data[i]=tempbyte;
19219
19220 5632 tempbyte=buf[131].data[i];
19221 5632 buf[131].data[i]=buf[133].data[i];
19222 5632 buf[133].data[i]=tempbyte;
19223 5632 }
19224 22 }
19225 83 }
19226
19227 787 al_trace("Registering blank tiles\n");
19228 787 register_blank_tiles();
19229
19230 //memset(temp_tile, 0, tilesize(tf32Bit));
19231
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 delete[] temp_tile;
19232 787 temp_tile=NULL;
19233 787 return 0;
19234 787 }
19235
19236 469 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19237 {
19238
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19239
19240 static byte fake_midi_flags[32];
19241
19242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19243 int32_t dummy;
19244 word dummy2;
19245 // zcmidi_ temp_midi;
19246 int32_t tunes_to_read;
19247 469 int32_t tune_count=0;
19248 469 word section_version=0;
19249 469 zctune temp;
19250
19251
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if(Header->zelda_version < 0x193)
19252 {
19253 // mf=Header->data_flags+ZQ_MIDIS2;
19254
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19255 {
19256 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19257 22 }
19258 else
19259 {
19260 1 tunes_to_read=MAXCUSTOMTUNES;
19261 }
19262 23 }
19263 else
19264 {
19265 //section version info
19266
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&section_version,f))
19267 {
19268 return qe_invalid;
19269 }
19270
19271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if (!should_skip)
19272 446 FFCore.quest_format[vMIDIs] = section_version;
19273
19274
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&dummy2,f))
19275 {
19276 return qe_invalid;
19277 }
19278
19279 //section size
19280
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
19281 {
19282 return qe_invalid;
19283 }
19284
19285 //finally... section data
19286
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!pfread(midi_flags,sizeof(midi_flags),f))
19287 {
19288 return qe_invalid;
19289 }
19290
19291 446 tunes_to_read=MAXCUSTOMTUNES;
19292 }
19293
19294
2/2
✓ Branch 0 taken 118188 times.
✓ Branch 1 taken 469 times.
118657 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19295 {
19296
2/2
✓ Branch 0 taken 10242 times.
✓ Branch 1 taken 107946 times.
118188 if(get_bit(mf, i))
19297 {
19298 10242 ++tune_count;
19299 10242 }
19300 118188 }
19301
19302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (!should_skip)
19303 469 reset_tunes(tunes); //reset_midis(midis);
19304
19305
2/2
✓ Branch 0 taken 113348 times.
✓ Branch 1 taken 469 times.
113817 for(int32_t i=0; i<tunes_to_read; i++)
19306 {
19307 113348 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19308
19309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113348 times.
113348 if (!should_skip)
19310 113348 tunes[i].reset(); // reset_midi(midis+i);
19311
19312
2/2
✓ Branch 0 taken 103106 times.
✓ Branch 1 taken 10242 times.
113348 if(get_bit(mf,i))
19313 {
19314
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7579 times.
10242 if(section_version < 4)
19315 {
19316
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19317 {
19318 return qe_invalid;
19319 }
19320 2663 }
19321 else
19322 {
19323
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19324 {
19325 return qe_invalid;
19326 }
19327 }
19328
19329
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetl(&temp.start,f))
19330 {
19331 return qe_invalid;
19332 }
19333
19334
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetl(&temp.loop_start,f))
19335 {
19336 return qe_invalid;
19337 }
19338
19339
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetl(&temp.loop_end,f))
19340 {
19341 return qe_invalid;
19342 }
19343
19344
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetw(&temp.loop,f))
19345 {
19346 return qe_invalid;
19347 }
19348
19349
1/2
✓ Branch 0 taken 10242 times.
✗ Branch 1 not taken.
10242 if(!p_igetw(&temp.volume,f))
19350 {
19351 return qe_invalid;
19352 }
19353
19354
2/2
✓ Branch 0 taken 9993 times.
✓ Branch 1 taken 249 times.
10242 if(Header->zelda_version < 0x193)
19355 {
19356
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19357 {
19358 return qe_invalid;
19359 }
19360 249 }
19361
19362
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7579 times.
10242 if(section_version >= 3)
19363 {
19364
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19365 {
19366 return qe_invalid;
19367 }
19368 7579 }
19369
19370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10242 times.
10242 if (!should_skip)
19371 10242 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19372
19373
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7579 times.
10242 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19374 {
19375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19376 {
19377 if (read_midi(f)==NULL)
19378 {
19379 return qe_invalid;
19380 }
19381
19382 continue;
19383 }
19384
19385 // old format - a midi is a midi
19386
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19387 {
19388 return qe_invalid;
19389 }
19390 2663 }
19391 else
19392 {
19393 byte format;
19394
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if(!pfread(&format,sizeof(format),f))
19395 {
19396 return qe_invalid;
19397 }
19398
19399 // MIDI is the only format saved here.
19400 // Never did more than MIDI for a zctune, and no plans to now.
19401
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if (format != MFORMAT_MIDI)
19402 {
19403 return qe_invalid;
19404 }
19405
19406 7579 tunes[i].data = read_midi(f);
19407
1/2
✓ Branch 0 taken 7579 times.
✗ Branch 1 not taken.
7579 if (!tunes[i].data)
19408 {
19409 return qe_invalid;
19410 }
19411 }
19412 10242 }
19413 113348 }
19414
19415 469 return 0;
19416 469 }
19417
19418 469 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19419 {
19420
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19421
19422 int32_t dummy;
19423 ZCHEATS tempzcheats;
19424 469 char temp_use_cheats=1;
19425 469 memset(&tempzcheats, 0, sizeof(tempzcheats));
19426 469 word s_version = 0;
19427
19428
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 446 times.
469 if(Header->zelda_version > 0x192)
19429 {
19430 //section version info
19431
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&s_version,f))
19432 {
19433 return qe_invalid;
19434 }
19435
19436 446 FFCore.quest_format[vCheats] = s_version;
19437
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetw(&dummy,f))
19438 {
19439 return qe_invalid;
19440 }
19441
19442 //section size
19443
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(!p_igetl(&dummy,f))
19444 {
19445 return qe_invalid;
19446 }
19447
19448 //finally... section data
19449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(!p_getc(&temp_use_cheats,f))
19450 {
19451 return qe_invalid;
19452 }
19453 446 }
19454
19455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(Header->data_flags[ZQ_CHEATS2])
19456 {
19457
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!p_igetl(&tempzcheats.flags,f))
19458 {
19459 return qe_invalid;
19460 }
19461
19462
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19463 {
19464 return qe_invalid;
19465 }
19466 469 }
19467
19468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if (should_skip)
19469 return 0;
19470
19471 469 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19472 469 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19473
19474 469 return 0;
19475 469 }
19476
19477 304 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19478 {
19479
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
304 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19480
19481 byte padding, tempbyte;
19482
19483 // Legacy item properties (now integrated into itemdata)
19484 byte sword_hearts[4];
19485 byte beam_hearts[4];
19486 304 byte beam_percent=0;
19487 word beam_power[4];
19488 304 byte hookshot_length=99;
19489 304 byte hookshot_links=100;
19490 304 byte longshot_length=99;
19491 304 byte longshot_links=100;
19492 304 byte moving_fairy_hearts=3;
19493 304 byte moving_fairy_heart_percent=0;
19494 304 byte stationary_fairy_hearts=3;
19495 304 byte stationary_fairy_heart_percent=0;
19496 304 byte moving_fairy_magic=0;
19497 304 byte moving_fairy_magic_percent=0;
19498 304 byte stationary_fairy_magic=0;
19499 304 byte stationary_fairy_magic_percent=0;
19500 304 byte blue_potion_hearts=100;
19501 304 byte blue_potion_heart_percent=1;
19502 304 byte red_potion_hearts=100;
19503 304 byte red_potion_heart_percent=1;
19504 304 byte blue_potion_magic=100;
19505 304 byte blue_potion_magic_percent=1;
19506 304 byte red_potion_magic=100;
19507 304 byte red_potion_magic_percent=1;
19508
19509 304 byte bomb_ratio = 4;
19510
19511 304 subscr_mode = 0;
19512
19513 /* HIGHLY UNORTHODOX UPDATING THING, by L
19514 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19515 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19516 * changing from 13 to 14.
19517 */
19518
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(s_version < 14)
19519 82 fixpolsvoice=true;
19520
19521 /* End highly unorthodox updating thing */
19522
19523
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 114 times.
304 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19524 114 temp_zinit.jump_hero_layer_threshold=0;
19525
19526
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 222 times.
304 if(s_version >= 10)
19527 {
19528 char temp;
19529
19530 //new-style items
19531
2/2
✓ Branch 0 taken 56832 times.
✓ Branch 1 taken 222 times.
57054 for(int32_t j=0; j<256; j++)
19532 {
19533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56832 times.
56832 if(!p_getc(&temp,f))
19534 return qe_invalid;
19535
19536 56832 temp_zinit.set_item(j, temp != 0);
19537 56832 }
19538 222 }
19539
19540
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19541 {
19542 char temp;
19543
19544 //finally... section data
19545
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
291 if((Header->zelda_version > 0x192)||
19546 //new only
19547
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19548 {
19549 //OLD-style items... sigh
19550
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 60 times.
282 if(s_version < 10)
19551 {
19552
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19553 {
19554 return qe_invalid;
19555 }
19556
19557 60 temp_zinit.set_item(iRaft, temp != 0);
19558
19559
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19560 {
19561 return qe_invalid;
19562 }
19563
19564 60 temp_zinit.set_item(iLadder, temp != 0);
19565
19566
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19567 {
19568 return qe_invalid;
19569 }
19570
19571 60 temp_zinit.set_item(iBook, temp != 0);
19572
19573
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19574 {
19575 return qe_invalid;
19576 }
19577
19578 60 temp_zinit.set_item(iMKey, temp != 0);
19579
19580
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19581 {
19582 return qe_invalid;
19583 }
19584
19585 60 temp_zinit.set_item(iFlippers, temp != 0);
19586
19587
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19588 {
19589 return qe_invalid;
19590 }
19591
19592 60 temp_zinit.set_item(iBoots, temp != 0);
19593 60 }
19594 282 }
19595
19596
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 10)
19597 {
19598 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19599
19600
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19601 {
19602 return qe_invalid;
19603 }
19604
19605
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19606 {
19607 return qe_invalid;
19608 }
19609
19610
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19611 {
19612 return qe_invalid;
19613 }
19614
19615
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19616 {
19617 return qe_invalid;
19618 }
19619
19620
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19621 {
19622 return qe_invalid;
19623 }
19624
19625
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19626 {
19627 return qe_invalid;
19628 }
19629
19630
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19631 {
19632 return qe_invalid;
19633 }
19634
19635 //old only
19636
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19637 {
19638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19640
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19645 4 }
19646
19647 //rings start at level 2... wtf
19648 //account for this -DD
19649 64 tempring <<= 1;
19650 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19651 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19652 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19653 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19654 //bracelet ALSO starts at level 2 :-( -DD
19655 64 tempbracelet<<=1;
19656 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19657 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19658 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19659
19660 //new only
19661
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19662 {
19663
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19664 {
19665
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19666 {
19667 return qe_invalid;
19668 }
19669 32 }
19670 1 }
19671
19672 char tempcandle, tempboomerang, temparrow, tempwhistle;
19673
19674
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19675 {
19676 return qe_invalid;
19677 }
19678
19679
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19680 {
19681 return qe_invalid;
19682 }
19683
19684
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19685 {
19686 return qe_invalid;
19687 }
19688
19689
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19690 {
19691 return qe_invalid;
19692 }
19693
19694 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19695
19696
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19697 {
19698 return qe_invalid;
19699 }
19700
19701 //old only
19702
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19703 {
19704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19708 4 }
19709
19710 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19711 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19712 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19713 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19714 //What about the potion...?
19715
19716 64 }
19717
19718
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if(s_version < 29)
19719 {
19720 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19721 //to jab out my eye...
19722
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19723 return qe_invalid;
19724 269 temp_zinit.counter[crBOMBS] = padding;
19725
19726
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19727 return qe_invalid;
19728 269 temp_zinit.counter[crSBOMBS] = padding;
19729 269 }
19730
19731 //Back to more OLD item code
19732
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 10)
19733 {
19734
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19735 //new only
19736
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19737 {
19738
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19739 {
19740 return qe_invalid;
19741 }
19742
19743 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19744
19745
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19746 {
19747 return qe_invalid;
19748 }
19749
19750 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19751
19752
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19753 {
19754 return qe_invalid;
19755 }
19756
19757 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19758
19759
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19760 {
19761 return qe_invalid;
19762 }
19763
19764 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19765
19766
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19767 {
19768 return qe_invalid;
19769 }
19770
19771 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19772
19773
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19774 {
19775 return qe_invalid;
19776 }
19777
19778 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19779
19780
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19781 {
19782 return qe_invalid;
19783 }
19784
19785 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19786
19787
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19788 {
19789 return qe_invalid;
19790 }
19791
19792 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19793
19794
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19795 {
19796 return qe_invalid;
19797 }
19798
19799 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19800
19801
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19802 {
19803 return qe_invalid;
19804 }
19805
19806
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
19807 {
19808
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19809 {
19810
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19811 {
19812 return qe_invalid;
19813 }
19814 32 }
19815 1 }
19816 60 }
19817 64 }
19818
19819 //old only
19820
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
19821 {
19822 byte equipment, tmpitm; //bit flags
19823
19824
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19825 {
19826 return qe_invalid;
19827 }
19828
19829 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19830 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19831 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19832 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19833 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19834 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19835
19836
19837
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19838 {
19839 return qe_invalid;
19840 }
19841
19842 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19843 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19844 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19845 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19846 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19847 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19848 4 }
19849
19850
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&tempbyte,f))
19851 return qe_invalid;
19852 286 temp_zinit.mcounter[crLIFE] = tempbyte;
19853
19854
19855
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 14)
19856 {
19857 byte temphp;
19858
19859
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19860 {
19861 return qe_invalid;
19862 }
19863
19864 64 temp_zinit.counter[crLIFE]=temphp;
19865
19866
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19867 {
19868 return qe_invalid;
19869 }
19870
19871 64 temp_zinit.cont_heart=temphp;
19872 64 }
19873 else
19874 {
19875
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19876 {
19877 return qe_invalid;
19878 }
19879
19880
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.cont_heart,f))
19881 {
19882 return qe_invalid;
19883 }
19884 }
19885
19886
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.hcp,f))
19887 {
19888 return qe_invalid;
19889 }
19890
19891
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version >= 14)
19892 {
19893
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19894 {
19895 return qe_invalid;
19896 }
19897
19898
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(s_version<16) // July 2007
19899 {
19900 if(get_qr(qr_BRANGPICKUP+1))
19901 temp_zinit.hcp_per_hc = 0xFF;
19902
19903 //Dispose of legacy rule
19904 set_qr(qr_BRANGPICKUP+1, 0);
19905 }
19906 222 }
19907
19908
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if(s_version < 29)
19909 {
19910
1/2
✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
269 if(!p_getc(&padding,f))
19911 return qe_invalid;
19912 269 temp_zinit.mcounter[crBOMBS] = padding;
19913 269 }
19914
19915
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19916 {
19917 return qe_invalid;
19918 }
19919
19920
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19921 {
19922 return qe_invalid;
19923 }
19924
19925
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&tempbyte,f))
19926 return qe_invalid;
19927
2/2
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 286 times.
2574 for(int q = 0; q < 8; ++q)
19928
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1784 times.
2288 SETFLAG(temp_zinit.litems[q+1], liTRIFORCE, get_bitl(tempbyte, q));
19929
19930 286 int level_count = 32;
19931
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
286 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19932 222 level_count = 64;
19933 byte tmp_map[64];
19934 byte tmp_compass[64];
19935
2/2
✓ Branch 0 taken 16256 times.
✓ Branch 1 taken 286 times.
16542 for(int32_t i=0; i<level_count; i++)
19936
1/2
✓ Branch 0 taken 16256 times.
✗ Branch 1 not taken.
16256 if(!p_getc(&tmp_map[i],f))
19937 return qe_invalid;
19938
2/2
✓ Branch 0 taken 16256 times.
✓ Branch 1 taken 286 times.
16542 for(int32_t i=0; i<level_count; i++)
19939
1/2
✓ Branch 0 taken 16256 times.
✗ Branch 1 not taken.
16256 if(!p_getc(&tmp_compass[i],f))
19940 return qe_invalid;
19941
2/2
✓ Branch 0 taken 130048 times.
✓ Branch 1 taken 286 times.
130334 for(int q = 0; q < level_count*8; ++q)
19942 {
19943
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 129252 times.
130048 SETFLAG(temp_zinit.litems[q], liMAP, get_bit(tmp_map, q));
19944
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 130039 times.
130048 SETFLAG(temp_zinit.litems[q], liCOMPASS, get_bit(tmp_compass, q));
19945 130048 }
19946
19947
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
291 if((Header->zelda_version > 0x192)||
19948 //new only
19949
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19950 {
19951 byte tmp_boss_key[64];
19952
2/2
✓ Branch 0 taken 16128 times.
✓ Branch 1 taken 282 times.
16410 for(int32_t i=0; i<level_count; i++)
19953 {
19954
1/2
✓ Branch 0 taken 16128 times.
✗ Branch 1 not taken.
16128 if(!p_getc(&tmp_boss_key[i],f))
19955 {
19956 return qe_invalid;
19957 }
19958 16128 }
19959
2/2
✓ Branch 0 taken 129024 times.
✓ Branch 1 taken 282 times.
129306 for(int q = 0; q < level_count*8; ++q)
19960 {
19961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129024 times.
129024 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
19962 129024 }
19963 282 }
19964
19965 byte tmpmisc[16];
19966
2/2
✓ Branch 0 taken 4576 times.
✓ Branch 1 taken 286 times.
4862 for(int32_t i=0; i<16; i++)
19967
1/2
✓ Branch 0 taken 4576 times.
✗ Branch 1 not taken.
4576 if(!p_getc(&tmpmisc[i],f))
19968 return qe_invalid;
19969 286 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19970 286 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19971 286 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19972
19973
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
542 if(s_version < 15) for(int32_t i=0; i<4; i++)
19974
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
19975 64 return qe_invalid;
19976
19977
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.last_map,f))
19978 {
19979 return qe_invalid;
19980 }
19981
19982
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.last_screen,f))
19983 {
19984 return qe_invalid;
19985 }
19986
19987
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 14)
19988 {
19989 byte tempmp;
19990
19991
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19992 {
19993 return qe_invalid;
19994 }
19995
19996 64 temp_zinit.mcounter[crMAGIC]=tempmp;
19997
19998
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19999 {
20000 return qe_invalid;
20001 }
20002
20003 64 temp_zinit.counter[crMAGIC]=tempmp;
20004 64 }
20005 else
20006 {
20007
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20008 {
20009 return qe_invalid;
20010 }
20011
20012
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20013 {
20014 return qe_invalid;
20015 }
20016 }
20017
20018
20019
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version < 15)
20020 {
20021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20022 {
20023 64 temp_zinit.mcounter[crMAGIC]*=32;
20024 64 temp_zinit.counter[crMAGIC]*=32;
20025 64 }
20026
20027
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20028 {
20029
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20030 {
20031 return qe_invalid;
20032 }
20033 256 }
20034
20035
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20036 {
20037 return qe_invalid;
20038 }
20039 64 }
20040 else
20041 {
20042
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.bomb_ratio,f))
20043 return qe_invalid;
20044
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(temp_zinit.bomb_ratio < 1)
20045 temp_zinit.bomb_ratio = 1;
20046 222 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20047 }
20048
20049
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version < 15)
20050 {
20051 byte tempbp;
20052
20053
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20054 {
20055
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20056 {
20057 return qe_invalid;
20058 }
20059
20060 256 beam_power[i]=tempbp;
20061 256 }
20062
20063
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20064 {
20065 return qe_invalid;
20066 }
20067
20068
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20069 {
20070 if(!p_getc(&hookshot_length,f))
20071 {
20072 return qe_invalid;
20073 }
20074
20075 if(!p_getc(&longshot_links,f))
20076 {
20077 return qe_invalid;
20078 }
20079
20080 if(!p_getc(&longshot_length,f))
20081 {
20082 return qe_invalid;
20083 }
20084 }
20085 64 }
20086
20087
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.msg_more_x,f))
20088 {
20089 return qe_invalid;
20090 }
20091
20092
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&temp_zinit.msg_more_y,f))
20093 {
20094 return qe_invalid;
20095 }
20096
20097
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(!p_getc(&subscr_mode,f))
20098 return qe_invalid;
20099
20100 //old only
20101
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
20102 {
20103 byte tmp_boss_key[32];
20104
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20105 {
20106
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20107 {
20108 return qe_invalid;
20109 }
20110 128 }
20111
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20112 {
20113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
20114 1024 }
20115 4 }
20116
20117
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
286 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20118 {
20119
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 222 times.
282 if(s_version <= 10)
20120 {
20121
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20122 {
20123 return qe_invalid;
20124 }
20125
20126 60 temp_zinit.start_dmap = (word)tempbyte;
20127 60 }
20128 else
20129 {
20130
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.start_dmap,f))
20131 {
20132 return qe_invalid;
20133 }
20134 }
20135
20136
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20137 {
20138 return qe_invalid;
20139 }
20140 282 }
20141
20142
4/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 205 times.
286 if(s_version>1 && s_version < 29)
20143 {
20144
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&padding,f))
20145 return qe_invalid;
20146 205 temp_zinit.counter[crARROWS] = padding;
20147
20148
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!p_getc(&padding,f))
20149 return qe_invalid;
20150 205 temp_zinit.mcounter[crARROWS] = padding;
20151 205 }
20152
20153
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>2)
20154 {
20155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(s_version <= 10)
20156 {
20157 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20158 {
20159 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20160 {
20161 return qe_invalid;
20162 }
20163 }
20164 }
20165 else
20166 {
20167
2/2
✓ Branch 0 taken 113664 times.
✓ Branch 1 taken 222 times.
113886 for(int32_t i=0; i<MAXLEVELS; i++)
20168 {
20169
1/2
✓ Branch 0 taken 113664 times.
✗ Branch 1 not taken.
113664 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20170 {
20171 return qe_invalid;
20172 }
20173 113664 }
20174 }
20175 222 }
20176
20177
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>3)
20178 {
20179
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20180 {
20181 return qe_invalid;
20182 }
20183
20184
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20185 {
20186 return qe_invalid;
20187 }
20188
20189
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20190 {
20191 return qe_invalid;
20192 }
20193
20194
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20195 {
20196 return qe_invalid;
20197 }
20198
20199
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20200 {
20201 return qe_invalid;
20202 }
20203
20204
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20205 {
20206 return qe_invalid;
20207 }
20208
20209
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20210 {
20211 return qe_invalid;
20212 }
20213
20214
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.ss_flags,f))
20215 {
20216 return qe_invalid;
20217 }
20218
20219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20221 222 }
20222
20223
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>4 && s_version<15)
20224 {
20225 if(!p_getc(&moving_fairy_hearts,f))
20226 {
20227 return qe_invalid;
20228 }
20229
20230 if(!p_getc(&moving_fairy_heart_percent,f))
20231 {
20232 return qe_invalid;
20233 }
20234 }
20235
20236
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>5 && s_version < 10)
20237 {
20238 if(!p_getc(&temp,f))
20239 {
20240 return qe_invalid;
20241 }
20242
20243 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20244 }
20245
20246
3/4
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
286 if(s_version>6 && s_version<15)
20247 {
20248 if(!p_getc(&stationary_fairy_hearts,f))
20249 {
20250 return qe_invalid;
20251 }
20252
20253 if(!p_getc(&stationary_fairy_heart_percent,f))
20254 {
20255 return qe_invalid;
20256 }
20257
20258 if(!p_getc(&moving_fairy_magic,f))
20259 {
20260 return qe_invalid;
20261 }
20262
20263 if(!p_getc(&moving_fairy_magic_percent,f))
20264 {
20265 return qe_invalid;
20266 }
20267
20268 if(!p_getc(&stationary_fairy_magic,f))
20269 {
20270 return qe_invalid;
20271 }
20272
20273 if(!p_getc(&stationary_fairy_magic_percent,f))
20274 {
20275 return qe_invalid;
20276 }
20277
20278 if(!p_getc(&blue_potion_hearts,f))
20279 {
20280 return qe_invalid;
20281 }
20282
20283 if(!p_getc(&blue_potion_heart_percent,f))
20284 {
20285 return qe_invalid;
20286 }
20287
20288 if(!p_getc(&red_potion_hearts,f))
20289 {
20290 return qe_invalid;
20291 }
20292
20293 if(!p_getc(&red_potion_heart_percent,f))
20294 {
20295 return qe_invalid;
20296 }
20297
20298 if(!p_getc(&blue_potion_magic,f))
20299 {
20300 return qe_invalid;
20301 }
20302
20303 if(!p_getc(&blue_potion_magic_percent,f))
20304 {
20305 return qe_invalid;
20306 }
20307
20308 if(!p_getc(&red_potion_magic,f))
20309 {
20310 return qe_invalid;
20311 }
20312
20313 if(!p_getc(&red_potion_magic_percent,f))
20314 {
20315 return qe_invalid;
20316 }
20317 }
20318
20319
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>6)
20320
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20321 return qe_invalid;
20322
20323
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>7)
20324 {
20325
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20326 {
20327 return qe_invalid;
20328 }
20329 222 }
20330
20331
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>8)
20332 {
20333
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20334 {
20335 return qe_invalid;
20336 }
20337
20338
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20339 {
20340 return qe_invalid;
20341 }
20342 222 }
20343
20344
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 64 times.
286 if(s_version>16)
20345 {
20346
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&tempbyte,f))
20347 {
20348 return qe_invalid;
20349 }
20350 222 temp_zinit.gravity = tempbyte*100;
20351
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetw(&temp_zinit.terminalv,f))
20352 {
20353 return qe_invalid;
20354 }
20355
20356
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.msg_speed,f))
20357 {
20358 return qe_invalid;
20359 }
20360
20361
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&padding,f))
20362 {
20363 return qe_invalid;
20364 }
20365
20366
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20367 {
20368 return qe_invalid;
20369 }
20370 222 }
20371
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20372 12 temp_zinit.msg_speed = 0;
20373
20374
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 222 times.
286 if(s_version>17)
20375 {
20376
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20377 {
20378 return qe_invalid;
20379 }
20380 222 }
20381
20382 //expaned init data for larger values in 2.55
20383
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 17 times.
286 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20384 {
20385
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20386 {
20387 return qe_invalid;
20388 }
20389
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20390 {
20391 return qe_invalid;
20392 }
20393
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20394 {
20395 return qe_invalid;
20396 }
20397
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20398 {
20399 return qe_invalid;
20400 }
20401
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20402 {
20403 return qe_invalid;
20404 }
20405
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20406 {
20407 return qe_invalid;
20408 }
20409
20410 17 }
20411
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if ( s_version >= 20 )
20412 {
20413
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20414 {
20415 return qe_invalid;
20416 }
20417 17 }
20418 else
20419 {
20420 269 temp_zinit.heroStep = 150; //1.5 pixels per frame
20421 }
20422
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 269 times.
286 if ( s_version >= 21 )
20423 {
20424
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20425 {
20426 return qe_invalid;
20427 }
20428 17 }
20429 else
20430 {
20431 269 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20432 }
20433 //old only
20434
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version == 0x192)&&(Header->build<174))
20435 {
20436 byte items2;
20437
20438
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20439 {
20440 return qe_invalid;
20441 }
20442
20443 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20444 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20445 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20446 4 }
20447
20448
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 5 times.
286 if(Header->zelda_version < 0x193)
20449 {
20450
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20451 {
20452
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20453 {
20454 return qe_invalid;
20455 }
20456 480 }
20457
20458 //new only
20459
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20460 {
20461
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20462 {
20463 return qe_invalid;
20464 }
20465
20466
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20467 {
20468 return qe_invalid;
20469 }
20470 1 }
20471 5 }
20472 286 }
20473
20474
3/6
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 222 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20475 {
20476 //temp_zinit.shield=i_smallshield;
20477 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20478
20479
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20480 82 temp_zinit.set_item(sshieldid, true);
20481 82 }
20482
20483
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20484 {
20485 18 temp_zinit.mcounter[crLIFE]=3;
20486 18 temp_zinit.counter[crLIFE]=3;
20487 18 temp_zinit.cont_heart=3;
20488 18 temp_zinit.mcounter[crBOMBS]=8;
20489 18 }
20490
20491
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20492 {
20493 18 sword_hearts[0]=0;
20494 18 sword_hearts[1]=5;
20495 18 sword_hearts[2]=12;
20496 18 sword_hearts[3]=21;
20497 18 }
20498
20499
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20500 {
20501 18 temp_zinit.last_map=0;
20502 18 temp_zinit.last_screen=0;
20503 18 }
20504
20505
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20506 {
20507 18 temp_zinit.mcounter[crMAGIC]=0;
20508 18 temp_zinit.counter[crMAGIC]=0;
20509 18 temp_zinit.magicdrainrate = 2;
20510 18 }
20511
20512
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20513 {
20514
20515
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20516 {
20517 72 beam_hearts[x]=100;
20518 72 }
20519
20520
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20521 {
20522 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20523 72 set_qr(qr_LENSHINTS+i,0);
20524 72 }
20525
20526
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20527 {
20528 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20529 72 }
20530
20531 18 set_qr(qr_HIDECARRIEDITEMS,0);
20532 18 hookshot_links=100;
20533 18 temp_zinit.msg_more_x=224;
20534 18 temp_zinit.msg_more_y=64;
20535 18 }
20536
20537 // Okay, let's put these legacy values into itemsbuf.
20538
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(s_version < 15)
20539
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20540 {
20541
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20542 {
20543 case iFairyStill:
20544 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20545 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20546 82 itemsbuf[i].misc3 = 0;
20547
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20548
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20549 82 break;
20550
20551 case iFairyMoving:
20552 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20553 82 itemsbuf[i].misc2 = moving_fairy_magic;
20554 82 itemsbuf[i].misc3 = 50;
20555
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20556
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20557 82 break;
20558
20559 case iRPotion:
20560 82 itemsbuf[i].misc1 = red_potion_hearts;
20561 82 itemsbuf[i].misc2 = red_potion_magic;
20562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20564 82 break;
20565
20566 case iBPotion:
20567 82 itemsbuf[i].misc1 = blue_potion_hearts;
20568 82 itemsbuf[i].misc2 = blue_potion_magic;
20569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20571 82 break;
20572
20573 case iSword:
20574 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20575 82 itemsbuf[i].misc1 = beam_hearts[0];
20576 82 itemsbuf[i].misc2 = beam_power[0];
20577 // It seems that item_flag1 was already added by reset_itembuf()...
20578 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20579 82 break;
20580
20581 case iWSword:
20582 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20583 82 itemsbuf[i].misc1 = beam_hearts[1];
20584 82 itemsbuf[i].misc2 = beam_power[1];
20585 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20586 82 break;
20587
20588 case iMSword:
20589 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20590 82 itemsbuf[i].misc1 = beam_hearts[2];
20591 82 itemsbuf[i].misc2 = beam_power[2];
20592 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20593 82 break;
20594
20595 case iXSword:
20596 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20597 82 itemsbuf[i].misc1 = beam_hearts[3];
20598 82 itemsbuf[i].misc2 = beam_power[3];
20599 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20600 82 break;
20601
20602 case iHookshot:
20603 82 itemsbuf[i].misc1 = hookshot_length;
20604 82 itemsbuf[i].misc2 = hookshot_links;
20605 82 break;
20606
20607 case iLongshot:
20608 82 itemsbuf[i].misc1 = longshot_length;
20609 82 itemsbuf[i].misc2 = longshot_links;
20610 82 break;
20611 }
20612 21074 }
20613
20614
6/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20615 {
20616 //was new subscreen rule
20617 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20618 22 set_qr(qr_FREEFORM,0);
20619 22 }
20620
20621
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20622 {
20623 23 temp_zinit.start_dmap=0;
20624 23 }
20625
20626
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
304 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20627 {
20628 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20629 23 }
20630
20631
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
304 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20632 {
20633 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20634 temp_zinit.mcounter[crMONEY]=999;
20635 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20636 }
20637
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 6 times.
304 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20638 {
20639 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20640 6 temp_zinit.mcounter[crBOMBS] = 8;
20641 6 }
20642 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20643 //time to ensure that we port all new values properly:
20644
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 82 times.
304 if(Header->zelda_version < 0x250)
20645 {
20646
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20647 82 }
20648
20649
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 21)
20650 {
20651
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
20652 {
20653 return qe_invalid;
20654 }
20655
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
20656 {
20657 return qe_invalid;
20658 }
20659
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20660 {
20661 return qe_invalid;
20662 }
20663
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20664 {
20665 return qe_invalid;
20666 }
20667 17 }
20668 else
20669 {
20670 287 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20671 287 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20672 287 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20673 287 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20674 }
20675
20676
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 22)
20677 {
20678
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
20680 return qe_invalid;
20681
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
20683 return qe_invalid;
20684 17 }
20685
20686
20687
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 23)
20688 {
20689
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
20690 {
20691 return qe_invalid;
20692 }
20693
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
20694 {
20695 return qe_invalid;
20696 }
20697
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
20698 {
20699 return qe_invalid;
20700 }
20701
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
20702 {
20703 return qe_invalid;
20704 }
20705
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
20706 {
20707 return qe_invalid;
20708 }
20709 17 }
20710 else
20711 {
20712 287 temp_zinit.dither_type = 0;
20713 287 temp_zinit.dither_arg = 0;
20714 287 temp_zinit.dither_percent = 20;
20715 287 temp_zinit.def_lightrad = 24;
20716 287 temp_zinit.transdark_percent = 0;
20717 }
20718
20719
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 24)
20720 {
20721
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
20722 {
20723 return qe_invalid;
20724 }
20725 17 }
20726 else
20727 {
20728 287 temp_zinit.darkcol = BLACK;
20729 }
20730
20731
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 25)
20732 {
20733
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
20734 {
20735 return qe_invalid;
20736 }
20737
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
20738 {
20739 return qe_invalid;
20740 }
20741 17 }
20742
20743
20744
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 26)
20745 {
20746
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20747 {
20748 return qe_invalid;
20749 }
20750
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20751 {
20752 return qe_invalid;
20753 }
20754
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20755 {
20756 return qe_invalid;
20757 }
20758 17 }
20759 else
20760 {
20761 287 temp_zinit.heroSideswimUpStep = 150;
20762 287 temp_zinit.heroSideswimSideStep = 100;
20763 287 temp_zinit.heroSideswimDownStep = 75;
20764 }
20765
20766
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 27)
20767 {
20768
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20769 {
20770 return qe_invalid;
20771 }
20772 17 }
20773 else
20774 {
20775 287 temp_zinit.exitWaterJump = 0;
20776 }
20777
20778
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 29)
20779 {
20780
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20781 {
20782 return qe_invalid;
20783 }
20784 17 }
20785 else
20786 {
20787 287 temp_zinit.bunny_ltm = 0;
20788 }
20789
20790
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 287 times.
304 if(s_version > 30)
20791 {
20792
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
20793 {
20794 return qe_invalid;
20795 }
20796 17 }
20797 else
20798 {
20799 287 temp_zinit.switchhookstyle = 1;
20800 }
20801
20802
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 17 times.
304 if(s_version > 31)
20803 {
20804
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
20805 {
20806 return qe_invalid;
20807 }
20808 17 }
20809
20810 304 temp_zinit.clear_genscript();
20811
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 12 times.
304 if(s_version > 32)
20812 {
20813 12 word numgenscript = 0;
20814
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
20815 return qe_invalid;
20816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
20817 return qe_invalid;
20818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
20819 {
20820 if(!p_getc(&tempbyte,f))
20821 return qe_invalid;
20822 if(!(tempbyte&2))
20823 continue;
20824 temp_zinit.gen_doscript.set(q, tempbyte&1);
20825 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20826 return qe_invalid;
20827 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20828 return qe_invalid;
20829 for(auto p = 0; p < 8; ++p)
20830 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20831 return qe_invalid;
20832 dword sz;
20833 if(!p_igetl(&sz,f))
20834 return qe_invalid;
20835 temp_zinit.gen_data[q].resize(sz);
20836 std::vector<int32_t> dummy;
20837 if(!p_getlvec(&dummy,f))
20838 return qe_invalid;
20839 temp_zinit.gen_data[q] = dummy;
20840 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20841 return qe_invalid;
20842 }
20843 12 }
20844
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 6 times.
304 if(s_version > 33)
20845 {
20846
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20847 return qe_invalid;
20848
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
20849 return qe_invalid;
20850 6 }
20851
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if(s_version > 34)
20852 {
20853 uint32_t num_used_mapscr_data;
20854 if(!p_igetl(&num_used_mapscr_data,f))
20855 return qe_invalid;
20856 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20857 {
20858 uint32_t sz;
20859 if(!p_igetl(&sz,f))
20860 return qe_invalid;
20861 temp_zinit.screen_data[q].resize(sz);
20862 if(sz)
20863 {
20864 std::vector<int32_t> dummy;
20865 if(!p_getlvec(&dummy,f))
20866 return qe_invalid;
20867 temp_zinit.screen_data[q] = dummy;
20868 }
20869 }
20870 }
20871
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (s_version > 35)
20872 if(!p_igetzf(&temp_zinit.shove_offset,f))
20873 return qe_invalid;
20874
20875 304 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20876 304 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20877
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 110 times.
304 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20878 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20879
20880 304 return 0;
20881 304 }
20882 469 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20883 {
20884 469 zinitdata temp_zinit = {};
20885
20886
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
469 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20887
20888 int32_t dummy;
20889 469 word s_version=0;
20890 byte padding;
20891
20892
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 23 times.
469 if(Header->zelda_version > 0x192)
20893 {
20894
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetw(&s_version,f))
20895 return qe_invalid;
20896 446 FFCore.quest_format[vInitData] = s_version;
20897
20898
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!read_deprecated_section_cversion(f))
20899 return qe_invalid;
20900
20901 //section size
20902
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!p_igetl(&dummy,f))
20903 return qe_invalid;
20904 446 }
20905
20906
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 165 times.
469 if(s_version < 37)
20907 {
20908
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 304 times.
304 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
20909 return ret;
20910 304 }
20911 else
20912 {
20913 165 subscr_mode = ssdtMAX;
20914
2/2
✓ Branch 0 taken 5280 times.
✓ Branch 1 taken 165 times.
5445 for(int q = 0; q < MAXITEMS/8; ++q)
20915
2/4
✓ Branch 0 taken 5280 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5280 times.
5280 if(!p_getc(&temp_zinit.items[q], f))
20916 return qe_invalid;
20917
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 46 times.
165 if(s_version >= 42)
20918 {
20919
2/2
✓ Branch 0 taken 60928 times.
✓ Branch 1 taken 119 times.
61047 for(int q = 0; q < MAXLEVELS; ++q)
20920 {
20921
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60928 times.
60928 if(!p_getc(&temp_zinit.litems[q], f))
20922 return qe_invalid;
20923 60928 }
20924 119 }
20925 else
20926 {
20927 byte tmp_map[MAXLEVELS/8];
20928 byte tmp_compass[MAXLEVELS/8];
20929 byte tmp_boss_key[MAXLEVELS/8];
20930 byte tmp_mcguffin[MAXLEVELS/8];
20931
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 46 times.
2990 for(int q = 0; q < MAXLEVELS/8; ++q)
20932 {
20933
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_map[q], f))
20934 return qe_invalid;
20935
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_compass[q], f))
20936 return qe_invalid;
20937
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_boss_key[q], f))
20938 return qe_invalid;
20939
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_mcguffin[q], f))
20940 return qe_invalid;
20941 2944 }
20942
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 46 times.
23598 for(int q = 0; q < MAXLEVELS; ++q)
20943 {
20944
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], liMAP, get_bit(tmp_map, q));
20945
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 23532 times.
23552 SETFLAG(temp_zinit.litems[q], liCOMPASS, get_bit(tmp_compass, q));
20946
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], liBOSSKEY, get_bit(tmp_boss_key, q));
20947
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 23408 times.
23552 SETFLAG(temp_zinit.litems[q], liTRIFORCE, get_bit(tmp_mcguffin, q));
20948 23552 }
20949 }
20950
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbvec(&temp_zinit.level_keys, f))
20951 return qe_invalid;
20952 byte num_counters;
20953
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&num_counters,f))
20954 return qe_invalid;
20955
2/2
✓ Branch 0 taken 17655 times.
✓ Branch 1 taken 165 times.
17820 for(int q = 0; q < num_counters; ++q)
20956
2/4
✓ Branch 0 taken 17655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17655 times.
17655 if(!p_igetw(&temp_zinit.counter[q],f))
20957 return qe_invalid;
20958
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 17655 times.
17820 for(int q = 0; q < num_counters; ++q)
20959
2/4
✓ Branch 0 taken 17655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17655 times.
17655 if(!p_igetw(&temp_zinit.mcounter[q],f))
20960 return qe_invalid;
20961
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.bomb_ratio,f))
20962 return qe_invalid;
20963
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hcp,f))
20964 return qe_invalid;
20965
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20966 return qe_invalid;
20967
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.cont_heart,f))
20968 return qe_invalid;
20969
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hp_per_heart,f))
20970 return qe_invalid;
20971
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.magic_per_block,f))
20972 return qe_invalid;
20973
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20974 return qe_invalid;
20975
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20976 return qe_invalid;
20977
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.dither_type,f))
20978 return qe_invalid;
20979
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.dither_arg,f))
20980 return qe_invalid;
20981
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.dither_percent,f))
20982 return qe_invalid;
20983
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.def_lightrad,f))
20984 return qe_invalid;
20985
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.transdark_percent,f))
20986 return qe_invalid;
20987
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.darkcol,f))
20988 return qe_invalid;
20989
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20990 return qe_invalid;
20991
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20992 return qe_invalid;
20993
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20994 return qe_invalid;
20995
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 165 times.
165 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20996 return qe_invalid;
20997
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20998 return qe_invalid;
20999
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21000 return qe_invalid;
21001
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21002 return qe_invalid;
21003
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.ss_flags,f))
21004 return qe_invalid;
21005
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbitstr(&temp_zinit.flags,f))
21006 return qe_invalid;
21007
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.last_map,f))
21008 return qe_invalid;
21009
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.last_screen,f))
21010 return qe_invalid;
21011
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.msg_more_x,f))
21012 return qe_invalid;
21013
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.msg_more_y,f))
21014 return qe_invalid;
21015
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21016 return qe_invalid;
21017
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.msg_speed,f))
21018 return qe_invalid;
21019
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.gravity,f))
21020 return qe_invalid;
21021
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.swimgravity,f))
21022 return qe_invalid;
21023
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.terminalv,f))
21024 return qe_invalid;
21025
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21026 return qe_invalid;
21027
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21028 return qe_invalid;
21029
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.hero_swim_div,f))
21030 return qe_invalid;
21031
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21032 return qe_invalid;
21033
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21034 return qe_invalid;
21035
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21036 return qe_invalid;
21037
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21038 return qe_invalid;
21039
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.heroStep,f))
21040 return qe_invalid;
21041
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21042 return qe_invalid;
21043
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21044 return qe_invalid;
21045
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21046 return qe_invalid;
21047
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.start_dmap,f))
21048 return qe_invalid;
21049
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21050 return qe_invalid;
21051
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.switchhookstyle,f))
21052 return qe_invalid;
21053
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getc(&temp_zinit.magicdrainrate,f))
21054 return qe_invalid;
21055
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_igetzf(&temp_zinit.shove_offset,f))
21056 return qe_invalid;
21057
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21058 return qe_invalid;
21059
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21060 return qe_invalid;
21061
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21062 return qe_invalid;
21063
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 165 times.
165 if(!p_getbmap(&temp_zinit.gen_initd, f))
21064 return qe_invalid;
21065
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21066 return qe_invalid;
21067
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.gen_data, f))
21068 return qe_invalid;
21069
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if(!p_getbmap(&temp_zinit.screen_data, f))
21070 return qe_invalid;
21071
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if (s_version >= 38)
21072 {
21073
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21074 return qe_invalid;
21075
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21076 return qe_invalid;
21077
2/4
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
165 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21078 return qe_invalid;
21079 165 }
21080
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 28 times.
165 if(s_version >= 39)
21081
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
137 if(!p_igetzf(&temp_zinit.air_drag, f))
21082 return qe_invalid;
21083
21084 // TODO: this first branch can likely be removed, as it only fixes an issues
21085 // that existed for a handful of temporary z3 builds (and active users of that
21086 // fork would have been updating often, beyond s_version 40).
21087
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
165 if (Header->is_z3 && s_version == 40)
21088 {
21089 if(!p_getc(&temp_zinit.region_mapping, f))
21090 return qe_invalid;
21091 }
21092 else
21093 {
21094
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 28 times.
165 if(s_version >= 40)
21095 {
21096
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
137 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21097 return qe_invalid;
21098
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
137 if(!p_igetw(&temp_zinit.light_wave_size, f))
21099 return qe_invalid;
21100 137 }
21101
21102
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 28 times.
165 if(s_version >= 41)
21103 {
21104
2/4
✓ Branch 0 taken 137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137 times.
✗ Branch 3 not taken.
137 if(!p_getc(&temp_zinit.region_mapping, f))
21105 return qe_invalid;
21106 137 }
21107 }
21108 }
21109
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if (should_skip)
21110 return 0;
21111
21112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(loading_tileset_flags & TILESET_CLEARMAPS)
21113 {
21114 temp_zinit.last_map = 0;
21115 temp_zinit.last_screen = 0;
21116 temp_zinit.screen_data.clear();
21117 }
21118
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 temp_zinit.normalize();
21119
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 zinit = temp_zinit;
21120
21121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(zinit.heroAnimationStyle==las_zelda3slow)
21122 {
21123 hero_animation_speed=2;
21124 }
21125 else
21126 {
21127 469 hero_animation_speed=1;
21128 }
21129
21130 469 return 0;
21131 469 }
21132
21133 /*
21134 void setupitemdropsets()
21135 {
21136 for(int32_t i=0; i<isMAX; i++)
21137 {
21138 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21139 }
21140 }
21141 */
21142
21143 410 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21144 {
21145
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 23 times.
410 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21146
21147 dword dummy_dword;
21148 410 word item_drop_sets_to_read=0;
21149 item_drop_object tempitemdrop;
21150 410 word s_version=0;
21151
21152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
410 if (!should_skip)
21153
2/2
✓ Branch 0 taken 104960 times.
✓ Branch 1 taken 410 times.
105370 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21154 {
21155 104960 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21156 105370 }
21157
21158
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 23 times.
410 if(version > 0x192)
21159 {
21160 387 item_drop_sets_to_read=0;
21161
21162 //section version info
21163
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&s_version,f))
21164 {
21165 return qe_invalid;
21166 }
21167
21168 387 FFCore.quest_format[vItemDropsets] = s_version;
21169
21170
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
21171 {
21172 return qe_invalid;
21173 }
21174
21175 //section size
21176
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy_dword,f))
21177 {
21178 return qe_invalid;
21179 }
21180
21181 //finally... section data
21182
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&item_drop_sets_to_read,f))
21183 {
21184 return qe_invalid;
21185 }
21186
21187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21188 {
21189 return qe_invalid;
21190 }
21191 387 }
21192 else
21193 {
21194 23 init_item_drop_sets();
21195 }
21196
21197
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 387 times.
410 if(s_version>=1)
21198 {
21199
2/2
✓ Branch 0 taken 5873 times.
✓ Branch 1 taken 387 times.
6260 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21200 {
21201
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21202 {
21203 return qe_invalid;
21204 }
21205
21206
2/2
✓ Branch 0 taken 58730 times.
✓ Branch 1 taken 5873 times.
64603 for(int32_t j=0; j<10; ++j)
21207 {
21208
1/2
✓ Branch 0 taken 58730 times.
✗ Branch 1 not taken.
58730 if(!p_igetw(&tempitemdrop.item[j],f))
21209 {
21210 return qe_invalid;
21211 }
21212 58730 }
21213
21214
2/2
✓ Branch 0 taken 64603 times.
✓ Branch 1 taken 5873 times.
70476 for(int32_t j=0; j<11; ++j)
21215 {
21216
1/2
✓ Branch 0 taken 64603 times.
✗ Branch 1 not taken.
64603 if(!p_igetw(&tempitemdrop.chance[j],f))
21217 {
21218 return qe_invalid;
21219 }
21220 64603 }
21221
21222 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21223 // overrides the quest's set #12.
21224
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5873 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5873 if(s_version<2 && i==12)
21225 continue;
21226
21227 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21228
1/4
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5873 if(s_version<2) for(int32_t j=0; j<10; ++j)
21229 {
21230 int32_t it = tempitemdrop.item[j];
21231
21232 if((itemsbuf[it].family == itype_rupee
21233 && ((itemsbuf[it].amount)&0xFFF) == 10)
21234 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21235 {
21236 tempitemdrop.chance[j+1]=0;
21237 }
21238 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21239 {
21240 tempitemdrop.chance[j+1]=0;
21241 }
21242
21243 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21244 if(itemsbuf[it].family == itype_misc)
21245 {
21246 // If a non-gameplay item was selected, then item drop was aborted.
21247 // Reflect this by increasing the 'Nothing' chance accordingly.
21248 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21249 tempitemdrop.chance[j+1]=0;
21250 }
21251 }
21252
21253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5873 times.
5873 if (!should_skip)
21254 5873 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21255 5873 }
21256 387 }
21257
21258 410 return 0;
21259 410 }
21260
21261 387 int32_t readfavorites(PACKFILE *f, int32_t)
21262 {
21263
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21264
21265 int32_t temp_num;
21266 dword dummy_dword;
21267 word num_favorite_combos;
21268 word num_favorite_combo_aliases;
21269 387 word s_version=0;
21270
21271 //section version info
21272
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&s_version,f))
21273 {
21274 return qe_invalid;
21275 }
21276
21277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if (!should_skip)
21278 387 FFCore.quest_format[vFavourites] = s_version;
21279
21280
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!read_deprecated_section_cversion(f))
21281 {
21282 return qe_invalid;
21283 }
21284
21285 //section size
21286
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&dummy_dword,f))
21287 {
21288 return qe_invalid;
21289 }
21290
21291 387 word per_row = FAVORITECOMBO_PER_ROW;
21292 387 word per_page = FAVORITECOMBO_PER_PAGE;
21293
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 171 times.
387 if(s_version >= 3)
21294
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(!p_igetw(&per_row,f))
21295 return qe_invalid;
21296
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 165 times.
387 if(s_version >= 4)
21297
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_igetw(&per_page,f))
21298 return qe_invalid;
21299 //finally... section data
21300
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&num_favorite_combos,f))
21301 {
21302 return qe_invalid;
21303 }
21304
21305 //Hack; port old favorite combos
21306
3/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 216 times.
387 if(s_version < 3 && num_favorite_combos == 100)
21307 216 per_row = 13;
21308
21309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if (!should_skip)
21310
2/2
✓ Branch 0 taken 487620 times.
✓ Branch 1 taken 387 times.
488007 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21311 488007 favorite_combos[q] = -1;
21312 387 byte favtype = 0;
21313
2/2
✓ Branch 0 taken 28048 times.
✓ Branch 1 taken 387 times.
28435 for(int32_t i=0; i<num_favorite_combos; i++)
21314 {
21315
2/2
✓ Branch 0 taken 6442 times.
✓ Branch 1 taken 21606 times.
28048 if (s_version >= 4)
21316 {
21317
1/2
✓ Branch 0 taken 6442 times.
✗ Branch 1 not taken.
6442 if (!p_getc(&favtype, f))
21318 {
21319 return qe_invalid;
21320 }
21321 6442 }
21322 else
21323 21606 favtype = 0;
21324
1/2
✓ Branch 0 taken 28048 times.
✗ Branch 1 not taken.
28048 if(!p_igetl(&temp_num,f))
21325 {
21326 return qe_invalid;
21327 }
21328
21329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28048 times.
28048 if (should_skip)
21330 continue;
21331
21332
2/2
✓ Branch 0 taken 6442 times.
✓ Branch 1 taken 21606 times.
28048 if(per_row == FAVORITECOMBO_PER_ROW)
21333 {
21334 6442 favorite_combos[i] = temp_num;
21335 6442 favorite_combo_modes[i] = favtype;
21336 6442 }
21337 else
21338 {
21339 21606 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21340 21606 favorite_combos[new_i]=temp_num;
21341 21606 favorite_combo_modes[new_i] = favtype;
21342 }
21343 28048 }
21344
21345 // Discard the separate favorite aliases list from previous versions
21346
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 222 times.
387 if(s_version<4)
21347 {
21348
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if (!p_igetw(&num_favorite_combo_aliases, f))
21349 {
21350 return qe_invalid;
21351 }
21352
21353
2/2
✓ Branch 0 taken 21600 times.
✓ Branch 1 taken 222 times.
21822 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21354 {
21355
1/2
✓ Branch 0 taken 21600 times.
✗ Branch 1 not taken.
21600 if (!p_igetl(&temp_num, f))
21356 {
21357 return qe_invalid;
21358 }
21359 21600 }
21360 222 }
21361
21362 387 word max_combo_cols = 0;
21363 387 word max_mappages = 0;
21364
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 171 times.
387 if(s_version >= 2)
21365 {
21366
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(!p_igetw(&max_combo_cols,f))
21367 return qe_invalid;
21368 171 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21369
2/2
✓ Branch 0 taken 684 times.
✓ Branch 1 taken 171 times.
855 for(int q = 0; q < max_combo_cols; ++q)
21370 {
21371
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&tmp,f))
21372 return qe_invalid;
21373
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&tmp2,f))
21374 return qe_invalid;
21375
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&tmp3,f))
21376 return qe_invalid;
21377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 684 times.
684 if(q < MAX_COMBO_COLS)
21378 {
21379 684 First[q] = tmp;
21380 684 combo_alistpos[q] = tmp2;
21381 684 combo_pool_listpos[q] = tmp3;
21382 684 }
21383 684 }
21384
21385
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(!p_igetw(&max_mappages,f))
21386 return qe_invalid;
21387
2/2
✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 171 times.
1710 for(int q = 0; q < max_mappages; ++q)
21388 {
21389
1/2
✓ Branch 0 taken 1539 times.
✗ Branch 1 not taken.
1539 if(!p_igetl(&tmp,f))
21390 return qe_invalid;
21391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
1539 if(!p_igetl(&tmp2,f))
21392 return qe_invalid;
21393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
1539 if(q < MAX_MAPPAGE_BTNS)
21394 {
21395 1539 map_page[q].map = tmp;
21396 1539 map_page[q].screen = tmp2;
21397 1539 }
21398 1539 }
21399 171 }
21400
21401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if (should_skip)
21402 return 0;
21403
21404
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 387 times.
1251 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21405 {
21406 864 First[q] = 0;
21407 864 combo_alistpos[q] = 0;
21408 864 combo_pool_listpos[q] = 0;
21409 864 }
21410
2/2
✓ Branch 0 taken 1944 times.
✓ Branch 1 taken 387 times.
2331 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21411 {
21412 1944 map_page[q].map = 0;
21413 1944 map_page[q].screen = 0;
21414 1944 }
21415
21416 387 return 0;
21417 387 }
21418
21419 /*
21420 switch (ret) {
21421 case 0:
21422 break;
21423
21424 case qe_invalid:
21425 goto invalid;
21426 break;
21427 default:
21428 pack_fclose(f);
21429 if(!oldquest)
21430 delete_file(tmpfilename);
21431 return ret;
21432 break;
21433 }
21434 */
21435
21436 const char *skip_text[skip_max]=
21437 {
21438 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21439 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21440 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21441 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21442 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21443 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21444 "skip_favorites"
21445 };
21446
21447
21448 void port250QuestRules(){
21449
21450 portCandleRules(); //Candle
21451 portBombRules();
21452
21453 }
21454
21455 void portCandleRules()
21456 {
21457 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21458 //itemdata itemsbuf;
21459 for ( int32_t q = 0; q < MAXITEMS; q++ )
21460 {
21461 if ( itemsbuf[q].family == itype_candle )
21462 {
21463 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21464 else itemsbuf[q].flags &= ~ item_flag2;
21465 }
21466 }
21467 }
21468
21469 void portBombRules()
21470 {
21471 bool hurtshero = get_qr(qr_OUCHBOMBS);
21472 //itemdata itemsbuf;
21473 for ( int32_t q = 0; q < MAXITEMS; q++ )
21474 {
21475 if ( itemsbuf[q].family == itype_bomb )
21476 {
21477 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21478 else itemsbuf[q].flags &= ~ item_flag2;
21479 }
21480 }
21481 }
21482
21483 18189 static int section_id_to_enum(int id)
21484 {
21485
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 787 times.
✓ Branch 3 taken 787 times.
✓ Branch 4 taken 787 times.
✓ Branch 5 taken 787 times.
✓ Branch 6 taken 704 times.
✓ Branch 7 taken 787 times.
✓ Branch 8 taken 787 times.
✓ Branch 9 taken 787 times.
✓ Branch 10 taken 787 times.
✓ Branch 11 taken 787 times.
✓ Branch 12 taken 787 times.
✓ Branch 13 taken 704 times.
✓ Branch 14 taken 704 times.
✓ Branch 15 taken 787 times.
✓ Branch 16 taken 787 times.
✓ Branch 17 taken 728 times.
✓ Branch 18 taken 704 times.
✓ Branch 19 taken 704 times.
✓ Branch 20 taken 704 times.
✓ Branch 21 taken 787 times.
✓ Branch 22 taken 787 times.
✓ Branch 23 taken 728 times.
✓ Branch 24 taken 704 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18189 switch (id)
21486 {
21487 case ID_HEADER: return skip_header;
21488 787 case ID_RULES: return skip_rules;
21489 787 case ID_STRINGS: return skip_strings;
21490 787 case ID_MISC: return skip_misc;
21491 787 case ID_TILES: return skip_tiles;
21492 787 case ID_COMBOS: return skip_combos;
21493 704 case ID_COMBOALIASES: return skip_comboaliases;
21494 787 case ID_CSETS: return skip_csets;
21495 787 case ID_MAPS: return skip_maps;
21496 787 case ID_DMAPS: return skip_dmaps;
21497 787 case ID_DOORS: return skip_doors;
21498 787 case ID_ITEMS: return skip_items;
21499 787 case ID_WEAPONS: return skip_weapons;
21500 704 case ID_COLORS: return skip_colors;
21501 704 case ID_ICONS: return skip_icons;
21502 787 case ID_INITDATA: return skip_initdata;
21503 787 case ID_GUYS: return skip_guys;
21504 728 case ID_HEROSPRITES: return skip_herosprites;
21505 704 case ID_SUBSCREEN: return skip_subscreens;
21506 704 case ID_FFSCRIPT: return skip_ffscript;
21507 704 case ID_SFX: return skip_sfx;
21508 787 case ID_MIDIS: return skip_midis;
21509 787 case ID_CHEATS: return skip_cheats;
21510 728 case ID_ITEMDROPSETS: return skip_itemdropsets;
21511 704 case ID_FAVORITES: return skip_favorites;
21512 case ID_ZINFO: return skip_zinfo;
21513 }
21514
21515 return -1;
21516 18189 }
21517
21518 17781 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21519 {
21520 17781 int section_enum = section_id_to_enum(section_id);
21521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17781 times.
17781 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21522
2/2
✓ Branch 0 taken 6657 times.
✓ Branch 1 taken 11124 times.
17781 if (skip)
21523 {
21524 word s_version;
21525
1/2
✓ Branch 0 taken 6657 times.
✗ Branch 1 not taken.
6657 if (!p_igetw(&s_version,f))
21526 {
21527 return qe_invalid;
21528 }
21529
21530
1/2
✓ Branch 0 taken 6657 times.
✗ Branch 1 not taken.
6657 if (!read_deprecated_section_cversion(f))
21531 {
21532 return qe_invalid;
21533 }
21534
21535
3/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6340 times.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
6657 if (section_id == ID_RULES && s_version > 16)
21536 {
21537 dword dummy;
21538 if (!p_igetl(&dummy,f))
21539 {
21540 return qe_invalid;
21541 }
21542 }
21543
21544
3/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6340 times.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
6657 if (section_id == ID_FFSCRIPT && s_version >= 18)
21545 {
21546 word dummy;
21547 if (!p_igetw(&dummy,f))
21548 {
21549 return qe_invalid;
21550 }
21551 }
21552
21553 dword section_length;
21554
1/2
✓ Branch 0 taken 6657 times.
✗ Branch 1 not taken.
6657 if (!p_igetl(&section_length,f))
21555 {
21556 return qe_invalid;
21557 }
21558
21559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6657 times.
6657 if (pack_fseek(f, section_length))
21560 {
21561 return qe_invalid;
21562 }
21563
21564
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6340 times.
6657 if (!pack_feof(f))
21565 {
21566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6340 times.
6340 if (!p_mgetl(&section_id,f))
21567 {
21568 return qe_invalid;
21569 }
21570 6340 }
21571
21572 6657 return qe_cancel;
21573 }
21574
21575 11124 return qe_OK;
21576 17781 }
21577
21578 // TODO: this was copied from zc/zasm_utils.cpp
21579 288 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21580 {
21581 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21582
21583 288 std::vector<zasm_script*> scripts;
21584
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 scripts.reserve(zasm_scripts.size());
21585
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 311361 times.
311649 for (auto& script : zasm_scripts)
21586
3/4
✓ Branch 0 taken 311361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8817 times.
✓ Branch 3 taken 302544 times.
311361 if (script->valid())
21587
1/2
✓ Branch 0 taken 8817 times.
✗ Branch 1 not taken.
8817 scripts.push_back(script.get());
21588
21589
2/4
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
288 std::for_each(scripts.begin(), scripts.end(), fn);
21590 288 }
21591
21592 469 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21593 {
21594 // 2.55.9 or newer?
21595
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 331 times.
469 if (header.compareVer(2, 55, 9) >= 0)
21596 138 return false; // defer to whatever was set
21597
21598 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
21599
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 281 times.
✓ Branch 2 taken 281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 281 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 281 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 281 times.
✓ Branch 12 taken 37 times.
✓ Branch 13 taken 294 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
331 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
21600 37 return true;
21601
21602 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
21603
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 std::string title = header.title;
21604
3/4
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 3 times.
294 if (title == "Stellar Seas")
21605 3 return false;
21606
3/4
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 288 times.
291 if (title == "Yuurand: Tales of the Labyrinth")
21607 3 return true;
21608
21609 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
21610 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
21611 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
21612 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
21613 288 bool found = false;
21614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
9105 _zasm_for_every_script([&](auto script){
21615
2/2
✓ Branch 0 taken 3034 times.
✓ Branch 1 taken 5783 times.
8817 if (found) return;
21616
21617
2/2
✓ Branch 0 taken 5751 times.
✓ Branch 1 taken 25292920 times.
25298671 for (const auto& instr : script->zasm)
21618 {
21619
4/4
✓ Branch 0 taken 22146115 times.
✓ Branch 1 taken 3146805 times.
✓ Branch 2 taken 367522 times.
✓ Branch 3 taken 21778593 times.
25292920 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
21620
21621 3514327 int value = instr.arg2;
21622
9/10
✓ Branch 0 taken 3514324 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3514320 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3514296 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3514296 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3514295 times.
3514327 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
21623 {
21624 32 found = true;
21625 32 break;
21626 }
21627 }
21628 8817 });
21629
21630 288 return found;
21631 469 }
21632
21633 //Internal function for loadquest wrapper
21634 787 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21635 {
21636 787 DMapEditorLastMaptileUsed = 0;
21637 787 combosread=false;
21638 787 mapsread=false;
21639 787 fixffcs=false;
21640
21641 787 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21642
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21643 {
21644 set_bit(skip_flags, skip_ffscript, 1);
21645 setZScriptVersion(V_FFSCRIPT);
21646 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21647 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21648 do_clear_scripts = true;
21649 }
21650
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(loading_tileset_flags & TILESET_CLEARMAPS)
21651 {
21652 set_bit(skip_flags, skip_maps, 1);
21653 }
21654
21655 // show_progress=true;
21656 char tmpfilename[L_tmpnam];
21657 787 temp_name(tmpfilename);
21658 // char percent_done[30];
21659 787 bool catchup=false;
21660 byte tempbyte;
21661 787 word old_map_count=map_count;
21662
21663 787 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21664 787 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21665 787 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21666
21667
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 318 times.
787 if(get_bit(skip_flags, skip_rules))
21668 {
21669 318 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21670 318 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21671 318 }
21672
21673 787 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21674 787 unpack_qrs();
21675 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21676
21677
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 318 times.
787 if(get_bit(skip_flags, skip_midis))
21678 {
21679 318 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21680 318 }
21681
21682
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 318 times.
787 if (!get_bit(skip_flags, skip_maps))
21683 469 Regions = {};
21684
21685
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 469 times.
787 if(do_clear_scripts)
21686 {
21687 469 zScript.clear();
21688 469 globalmap.clear();
21689 469 genericmap.clear();
21690 469 ffcmap.clear();
21691 469 itemmap.clear();
21692 469 npcmap.clear();
21693 469 ewpnmap.clear();
21694 469 lwpnmap.clear();
21695 469 playermap.clear();
21696 469 dmapmap.clear();
21697 469 screenmap.clear();
21698 469 itemspritemap.clear();
21699 469 comboscriptmap.clear();
21700 469 subscreenmap.clear();
21701
21702
2/2
✓ Branch 0 taken 239659 times.
✓ Branch 1 taken 469 times.
240128 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21703 {
21704 239659 ffcmap[i].clear();
21705 239659 }
21706
21707 469 globalmap[0].slotname = "Slot 1:";
21708 469 globalmap[0].scriptname = "~Init";
21709 469 globalmap[0].update();
21710
21711
2/2
✓ Branch 0 taken 3283 times.
✓ Branch 1 taken 469 times.
3752 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21712 {
21713 3283 globalmap[i].clear();
21714 3283 }
21715
21716
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21717 {
21718 119595 itemmap[i].clear();
21719 119595 }
21720
21721 //new script types -- prevent carrying over to a quest that you load after reading them
21722 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21723
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21724 {
21725 119595 npcmap[i].clear();
21726 119595 }
21727
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21728 {
21729 119595 lwpnmap[i].clear();
21730 119595 }
21731
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21732 {
21733 119595 ewpnmap[i].clear();
21734 119595 }
21735
2/2
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 469 times.
2345 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
21736 {
21737 1876 playermap[i].clear();
21738 1876 }
21739
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21740 {
21741 119595 dmapmap[i].clear();
21742 119595 }
21743
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21744 {
21745 119595 screenmap[i].clear();
21746 119595 }
21747
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21748 {
21749 119595 itemspritemap[i].clear();
21750 119595 }
21751
2/2
✓ Branch 0 taken 239659 times.
✓ Branch 1 taken 469 times.
240128 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21752 {
21753 239659 comboscriptmap[i].clear();
21754 239659 }
21755
2/2
✓ Branch 0 taken 239659 times.
✓ Branch 1 taken 469 times.
240128 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21756 {
21757 239659 genericmap[i].clear();
21758 239659 }
21759
2/2
✓ Branch 0 taken 119595 times.
✓ Branch 1 taken 469 times.
120064 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21760 {
21761 119595 subscreenmap[i].clear();
21762 119595 }
21763
21764 469 reset_scripts();
21765 469 }
21766
21767 787 zquestheader tempheader{};
21768
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 tempheader.filename = filename;
21769
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 zinfo tempzi;
21770
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 tempzi.clear();
21771 787 load_tmp_zi = &tempzi;
21772
21773 // oldquest flag is set when an unencrypted qst file is suspected.
21774 787 bool oldquest = false;
21775 787 int32_t open_error=0;
21776
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21777
21778
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if (!f)
21779 {
21780 ASSERT(open_error != 0);
21781 return open_error;
21782 }
21783 char zinfofilename[2048];
21784
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 replace_extension(zinfofilename, filename, "zinfo", 2047);
21785 787 int32_t ret=0;
21786
21787 //header
21788
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_out("Reading Header...");
21789
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 ret=readheader(f, &tempheader, printmetadata);
21790
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
787 checkstatus(ret);
21791
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_out("okay.");
21792
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_eol();
21793
21794
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 605 times.
787 if(read_zinfo)
21795 {
21796
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 box_out("Reading ZInfo - ");
21797
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
182 box_out(read_ext_zinfo ? "External..." : "Internal...");
21798
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 179 times.
182 if(read_ext_zinfo)
21799 {
21800
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21801
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
21802
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
21803
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
21804 3 }
21805 else
21806 {
21807
1/2
✓ Branch 0 taken 179 times.
✗ Branch 1 not taken.
179 ret=readzinfo(f, tempzi, tempheader);
21808
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
179 checkstatus(ret);
21809 }
21810
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 box_out("okay.");
21811
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 box_eol();
21812 182 }
21813
21814
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 24 times.
787 if(tempheader.zelda_version>=0x193)
21815 {
21816 dword section_id;
21817
21818 //section id
21819
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
763 if(!p_mgetl(&section_id,f))
21820 {
21821 goto invalid;
21822 }
21823
21824 763 std::set<dword> seen_sections;
21825
21826
3/4
✓ Branch 0 taken 18544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17781 times.
✓ Branch 3 taken 763 times.
18544 while(!pack_feof(f))
21827 {
21828
2/4
✓ Branch 0 taken 17781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17781 times.
✗ Branch 3 not taken.
17781 if (seen_sections.contains(section_id))
21829 goto invalid;
21830
1/2
✓ Branch 0 taken 17781 times.
✗ Branch 1 not taken.
17781 seen_sections.insert(section_id);
21831
21832
3/4
✓ Branch 0 taken 17781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11124 times.
✓ Branch 3 taken 6657 times.
17781 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21833 {
21834
1/2
✓ Branch 0 taken 6657 times.
✗ Branch 1 not taken.
6657 if (retval == qe_cancel)
21835 6657 continue;
21836 checkstatus(retval);
21837 }
21838
21839
24/25
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 446 times.
✓ Branch 2 taken 763 times.
✓ Branch 3 taken 763 times.
✓ Branch 4 taken 446 times.
✓ Branch 5 taken 387 times.
✓ Branch 6 taken 763 times.
✓ Branch 7 taken 446 times.
✓ Branch 8 taken 446 times.
✓ Branch 9 taken 446 times.
✓ Branch 10 taken 446 times.
✓ Branch 11 taken 446 times.
✓ Branch 12 taken 387 times.
✓ Branch 13 taken 387 times.
✓ Branch 14 taken 446 times.
✓ Branch 15 taken 446 times.
✓ Branch 16 taken 387 times.
✓ Branch 17 taken 387 times.
✓ Branch 18 taken 387 times.
✓ Branch 19 taken 387 times.
✓ Branch 20 taken 446 times.
✓ Branch 21 taken 446 times.
✓ Branch 22 taken 387 times.
✓ Branch 23 taken 387 times.
✗ Branch 24 not taken.
11124 switch(section_id)
21840 {
21841 case ID_RULES:
21842
21843 //rules
21844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21845 {
21846 box_out("found.");
21847 box_eol();
21848 catchup=false;
21849 }
21850
21851
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Rules...");
21852
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readrules(f, &tempheader);
21853
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21854
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21855
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21856 446 break;
21857
21858 case ID_STRINGS:
21859
21860 //strings
21861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21862 {
21863 box_out("found.");
21864 box_eol();
21865 catchup=false;
21866 }
21867
21868
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Strings...");
21869
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readstrings(f, &tempheader);
21870
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21871
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21872
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21873 446 break;
21874
21875 case ID_MISC:
21876
21877 //misc data
21878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(catchup)
21879 {
21880 box_out("found.");
21881 box_eol();
21882 catchup=false;
21883 }
21884
21885
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("Reading Misc. Data...");
21886
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 ret=readmisc(f, &tempheader, Misc);
21887
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
763 checkstatus(ret);
21888
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("okay.");
21889
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_eol();
21890 763 break;
21891
21892 case ID_TILES:
21893
21894 //tiles
21895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(catchup)
21896 {
21897 box_out("found.");
21898 box_eol();
21899 catchup=false;
21900 }
21901
21902
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("Reading Tiles...");
21903
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21904
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
763 checkstatus(ret);
21905
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("okay.");
21906
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_eol();
21907 763 break;
21908
21909 case ID_COMBOS:
21910
21911 //combos
21912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21913 {
21914 box_out("found.");
21915 box_eol();
21916 catchup=false;
21917 }
21918
21919
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Combos...");
21920
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21921 446 combosread=true;
21922
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21923
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21924
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21925 446 break;
21926
21927 case ID_COMBOALIASES:
21928
21929 //combo aliases
21930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
21931 {
21932 box_out("found.");
21933 box_eol();
21934 catchup=false;
21935 }
21936
21937
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Combo Aliases...");
21938
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21939
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
21940
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
21941
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
21942 387 break;
21943
21944 case ID_CSETS:
21945
21946 //color data
21947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(catchup)
21948 {
21949 box_out("found.");
21950 box_eol();
21951 catchup=false;
21952 }
21953
21954
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("Reading Color Data...");
21955
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21956
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
763 checkstatus(ret);
21957
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_out("okay.");
21958
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 box_eol();
21959 763 break;
21960
21961 case ID_MAPS:
21962
21963 //maps
21964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21965 {
21966 box_out("found.");
21967 box_eol();
21968 catchup=false;
21969 }
21970
21971
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Maps...");
21972
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readmaps(f, &tempheader);
21973 446 mapsread=true;
21974
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21975
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21976
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21977 446 break;
21978
21979 case ID_DMAPS:
21980
21981 //dmaps
21982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
21983 {
21984 box_out("found.");
21985 box_eol();
21986 catchup=false;
21987 }
21988
21989
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading DMaps...");
21990
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21991
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
21992
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
21993
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
21994 446 break;
21995
21996 case ID_DOORS:
21997
21998 //door combo sets
21999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22000 {
22001 box_out("found.");
22002 box_eol();
22003 catchup=false;
22004 }
22005
22006
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Doors...");
22007
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readdoorcombosets(f, &tempheader);
22008
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22009
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22010
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22011 446 break;
22012
22013 case ID_ITEMS:
22014
22015 //items
22016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22017 {
22018 box_out("found.");
22019 box_eol();
22020 catchup=false;
22021 }
22022
22023
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Items...");
22024
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22025
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22026
22027
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22028
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22029 446 break;
22030
22031 case ID_WEAPONS:
22032
22033 //weapons
22034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22035 {
22036 box_out("found.");
22037 box_eol();
22038 catchup=false;
22039 }
22040
22041
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Weapons...");
22042
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readweapons(f, &tempheader);
22043
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22044
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22045
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22046 446 break;
22047
22048 case ID_COLORS:
22049
22050 //misc. colors
22051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22052 {
22053 box_out("found.");
22054 box_eol();
22055 catchup=false;
22056 }
22057
22058
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Misc. Colors...");
22059
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readmisccolors(f, &tempheader, Misc);
22060
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22061
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22062
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22063 387 break;
22064
22065 case ID_ICONS:
22066
22067 //game icons
22068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22069 {
22070 box_out("found.");
22071 box_eol();
22072 catchup=false;
22073 }
22074
22075
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Game Icons...");
22076
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readgameicons(f, &tempheader, Misc);
22077
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22078
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22079
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22080 387 break;
22081
22082 case ID_INITDATA:
22083
22084 //initialization data
22085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22086 {
22087 box_out("found.");
22088 box_eol();
22089 catchup=false;
22090 }
22091
22092
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Init. Data...");
22093
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readinitdata(f, &tempheader);
22094
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22095
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22096
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22097
22098
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
446 if(!get_bit(skip_flags, skip_subscreens))
22099 {
22100
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 353 times.
446 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22101 {
22102
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 setupsubscreens();
22103
22104
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 93 times.
47709 for(int32_t i=0; i<MAXDMAPS; ++i)
22105 {
22106 47616 int32_t type=DMaps[i].type&dmfTYPE;
22107
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 46531 times.
47616 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22108 47616 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22109 47616 }
22110 93 }
22111 446 }
22112
22113
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!get_bit(skip_flags, skip_sfx))
22114 {
22115 446 setupsfx();
22116 446 }
22117
22118
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 446 times.
✗ Branch 3 not taken.
446 if(!get_bit(skip_flags, skip_itemdropsets))
22119 {
22120
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 init_item_drop_sets();
22121 446 }
22122
22123
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
446 if(!get_bit(skip_flags, skip_favorites))
22124 {
22125 446 init_favorites();
22126 446 }
22127
22128 446 break;
22129
22130 case ID_GUYS:
22131
22132 //guys
22133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22134 {
22135 box_out("found.");
22136 box_eol();
22137 catchup=false;
22138 }
22139
22140
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Custom Guy Data...");
22141
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readguys(f, &tempheader);
22142
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22143
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22144
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22145 446 break;
22146
22147 case ID_HEROSPRITES:
22148
22149 //hero sprites
22150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22151 {
22152 box_out("found.");
22153 box_eol();
22154 catchup=false;
22155 }
22156
22157
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Custom Hero Sprite Data...");
22158
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readherosprites(f, &tempheader);
22159
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22160
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22161
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22162 387 break;
22163
22164 case ID_SUBSCREEN:
22165
22166 //custom subscreens
22167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22168 {
22169 box_out("found.");
22170 box_eol();
22171 catchup=false;
22172 }
22173
22174
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Custom Subscreen Data...");
22175
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readsubscreens(f);
22176
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22177
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22178
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22179 387 break;
22180
22181 case ID_FFSCRIPT:
22182
22183 //Freeform combo scripts
22184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22185 {
22186 box_out("found.");
22187 box_eol();
22188 catchup=false;
22189 }
22190
22191
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading FF Script Data...");
22192
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readffscript(f, &tempheader);
22193
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22194
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22195
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22196 387 break;
22197
22198 case ID_SFX:
22199
22200 //SFX data
22201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22202 {
22203 box_out("found.");
22204 box_eol();
22205 catchup=false;
22206 }
22207
22208
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading SFX Data...");
22209
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readsfx(f, &tempheader);
22210
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22211
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22212
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22213 387 break;
22214
22215 case ID_MIDIS:
22216
22217 //midis
22218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22219 {
22220 box_out("found.");
22221 box_eol();
22222 catchup=false;
22223 }
22224
22225
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Tunes...");
22226
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readtunes(f, &tempheader, tunes);
22227
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22228
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22229
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22230 446 break;
22231
22232 case ID_CHEATS:
22233
22234 //cheat codes
22235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 if(catchup)
22236 {
22237 box_out("found.");
22238 box_eol();
22239 catchup=false;
22240 }
22241
22242
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("Reading Cheat Codes...");
22243
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 ret=readcheatcodes(f, &tempheader);
22244
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
446 checkstatus(ret);
22245
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_out("okay.");
22246
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 box_eol();
22247 446 break;
22248
22249 case ID_ITEMDROPSETS:
22250
22251 //item drop sets
22252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22253 {
22254 box_out("found.");
22255 box_eol();
22256 catchup=false;
22257 }
22258
22259
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Item Drop Sets...");
22260
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readitemdropsets(f, tempheader.zelda_version);
22261
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22262
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22263
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22264 387 break;
22265
22266 case ID_FAVORITES:
22267
22268 //favorite combos and combo aliases
22269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(catchup)
22270 {
22271 box_out("found.");
22272 box_eol();
22273 catchup=false;
22274 }
22275
22276
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("Reading Favorite Combos...");
22277
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 ret=readfavorites(f, tempheader.zelda_version);
22278
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
387 checkstatus(ret);
22279
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_out("okay.");
22280
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 box_eol();
22281 387 break;
22282
22283 default:
22284 if(!catchup)
22285 {
22286 box_out("Bad token! Searching...");
22287 box_eol();
22288 }
22289
22290 catchup=true;
22291 break;
22292 }
22293
22294
22295
1/2
✓ Branch 0 taken 11124 times.
✗ Branch 1 not taken.
11124 if(catchup)
22296 {
22297 //section id
22298 section_id=(section_id<<8);
22299
22300 if(!p_getc(&tempbyte,f))
22301 {
22302 goto invalid;
22303 }
22304
22305 section_id+=tempbyte;
22306 }
22307
22308 else
22309 {
22310 //section id
22311
3/4
✓ Branch 0 taken 11124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10678 times.
✓ Branch 3 taken 446 times.
11124 if(!pack_feof(f))
22312 {
22313
2/4
✓ Branch 0 taken 10678 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10678 times.
✗ Branch 3 not taken.
10678 if(!p_mgetl(&section_id,f))
22314 {
22315 goto invalid;
22316 }
22317 10678 }
22318 }
22319 }
22320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 }
22321 else
22322 {
22323
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22324
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22325
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22326
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22327
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22328
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22329
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22330
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22331
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22332
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22333
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22334
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22335
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22336
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22337
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22338
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22339
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22340
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22341 };
22342
22343 24 legacy_skip_flags = skip_flags;
22344
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22345 {
22346
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22347
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22348
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22349 {
22350 // Nothing to read.
22351
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22352 1 continue;
22353
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22354 1 continue;
22355
22356 // Haven't looked at how to skip these, because we don't need to currently: the only
22357 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22358
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22359 1 continue;
22360
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22361 1 continue;
22362
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22363 1 continue;
22364
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22365 1 continue;
22366
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22367 1 continue;
22368 9 }
22369
22370 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22371 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22372 // read all the sections even if requested to skip some.
22373 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22374 // {
22375 // if (retval == qe_cancel)
22376 // continue;
22377 // checkstatus(retval);
22378 // }
22379
22380
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22381
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22382
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22383
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22384
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22385 }
22386 24 legacy_skip_flags = nullptr;
22387
22388
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22389 {
22390
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22391
22392
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22393 {
22394 11776 int32_t type=DMaps[i].type&dmfTYPE;
22395
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22396 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22397 11776 }
22398 23 }
22399
22400
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22401
22402
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22403 23 setupsfx();
22404
22405
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22406 23 init_favorites();
22407
22408
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22409
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22410
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22411
22412
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 init_spritelists();
22413
22414 // check data
22415
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(f)
22416 {
22417
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 pack_fclose(f);
22418 787 }
22419
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 clear_quest_tmpfile();
22420
22421
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(!oldquest)
22422 {
22423
2/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 787 times.
787 if(exists(tmpfilename))
22424 {
22425 delete_file(tmpfilename);
22426 }
22427 787 }
22428
22429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
787 if(fixffcs && combosread && mapsread)
22430 {
22431 for(int32_t i=0; i<map_count; i++)
22432 {
22433 for(int32_t j=0; j<MAPSCRS; j++)
22434 {
22435 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22436 for(int32_t m=0; m<c; m++)
22437 {
22438 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22439 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22440 }
22441 }
22442 }
22443 }
22444
22445
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 318 times.
787 if (!get_bit(skip_flags, skip_rules))
22446 {
22447
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22448
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22449
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 397 times.
469 if (should_hide)
22450
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22451
22452
3/4
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 350 times.
469 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22453 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22454 469 }
22455
22456
7/10
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 723 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 63 times.
✗ Branch 9 not taken.
787 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22457 {
22458
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_CONTFULL_DEP, 0);
22459
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22460 63 zinit.cont_heart=100;
22461 63 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22462 63 }
22463
22464
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_out("Done.");
22465
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_eol();
22466
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 box_end(false);
22467
22468
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470 times.
✓ Branch 3 taken 317 times.
787 if(!get_bit(skip_flags, skip_header))
22469 {
22470
1/2
✓ Branch 0 taken 470 times.
✗ Branch 1 not taken.
470 *Header = tempheader;
22471 470 }
22472
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 318 times.
787 if(!get_bit(skip_flags, skip_zinfo))
22473 {
22474
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 ZI.copyFrom(tempzi);
22475 469 }
22476
22477
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 318 times.
787 if(get_bit(skip_flags, skip_maps))
22478 {
22479 318 map_count=old_map_count;
22480 318 }
22481
22482
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 318 times.
✓ Branch 3 taken 469 times.
787 if(get_bit(skip_flags, skip_rules))
22483 {
22484 318 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22485 318 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22486
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 unpack_qrs();
22487 318 }
22488
22489
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 318 times.
✓ Branch 3 taken 469 times.
787 if(get_bit(skip_flags, skip_midis))
22490 {
22491 318 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22492 318 }
22493
22494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if(loading_tileset_flags & TILESET_CLEARMAPS)
22495 {
22496 TheMaps.clear();
22497 TheMaps.resize(MAPSCRS*1);
22498 map_count = 1;
22499 map_autolayers.clear();
22500 map_autolayers.resize(6*1);
22501 }
22502
22503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if(loading_tileset_flags & TILESET_CLEARHEADER)
22504 {
22505 memset(Header->password, 0, sizeof(Header->password));
22506 memset(Header->minver, 0, sizeof(Header->minver));
22507 memset(Header->title, 0, sizeof(Header->title));
22508 memset(Header->author, 0, sizeof(Header->author));
22509 memset(Header->version, 0, sizeof(Header->version));
22510 Header->use_keyfile = 0;
22511 Header->dirty_password = false;
22512 cvs_MD5Context ctx;
22513 cvs_MD5Init(&ctx);
22514 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22515 cvs_MD5Final(Header->pwd_hash, &ctx);
22516 }
22517
22518
3/4
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 318 times.
787 if (!get_bit(skip_flags, skip_maps))
22519 {
22520 // Not needed, so release its memory.
22521
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 old_combo_pages = {};
22522 469 }
22523
22524 787 return qe_OK;
22525
22526 invalid:
22527 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22528 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22529 box_out("error.");
22530 box_eol();
22531 box_end(true);
22532
22533 pack_fclose(f);
22534
22535 if(!oldquest)
22536 {
22537 if(exists(tmpfilename))
22538 {
22539 delete_file(tmpfilename);
22540 }
22541 }
22542
22543 return qe_invalid;
22544
22545 787 }
22546
22547 static bool _is_loading_quest;
22548
22549 bool is_loading_quest()
22550 {
22551 return _is_loading_quest;
22552 }
22553
22554 317 std::string get_last_loaded_qstpath()
22555 {
22556 317 return last_loaded_qstpath;
22557 }
22558
22559 787 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22560 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22561 bool report, byte qst_num, dword tilesetflags)
22562 {
22563 787 loading_tileset_flags = tilesetflags;
22564 787 const char* basename = get_filename(filename);
22565 787 zapp_reporting_add_breadcrumb("load_quest", basename);
22566 787 zapp_reporting_set_tag("qst.filename", basename);
22567
22568 787 last_loaded_qstpath = filename;
22569 787 loading_qst_name = filename;
22570 787 loading_qst_num = qst_num;
22571 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22572 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22573
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if (!is_ci())
22574 loadquest_report = report;
22575
22576 787 _is_loading_quest = true;
22577 787 auto start = std::chrono::steady_clock::now();
22578 787 zprint2("Loading qst: %s\n", filename);
22579 787 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22580 787 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22581 787 zprint2("Time to load qst: %d ms\n", load_ms);
22582 787 _is_loading_quest = false;
22583
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if (ret)
22584 zprint2("Error: %s\n", qst_error[ret]);
22585
22586
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(show_progress)
22587 {
22588 if(ret)
22589 {
22590 box_out("-- Error loading quest file! --");
22591 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
22592 box_end(true);
22593 }
22594 else box_end(false);
22595 }
22596
22597 787 load_tmp_zi = NULL;
22598 787 loading_qst_name = NULL;
22599 787 loadquest_report = false;
22600 787 loading_qst_num = 0;
22601
22602 787 zapp_reporting_set_tag("qst.author", Header->author);
22603 787 zapp_reporting_set_tag("qst.title", Header->title);
22604 787 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22605
22606 787 return ret;
22607 }
22608